wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Java Exceptions and Errors Worksheet

Total questions: 72

Worksheet time: 39mins

Name
Class
Date
1.

the process of identifying and rectifying errors in a program that leads to unexpected behavior

a)

Exception Handling

b)

Debugging

c)

Rubber Ducking

d)

Error Class

2.

also known as backward debugging

a)

Backtracking

b)

Clustering Bugs

c)

Stepping

d)

Binary Search

3.

the point in the code to temporarily stop the execution of the program to inspect the state of its functionality.

a)

Stepping

b)

Rubber Ducking

c)

Binary Search

d)

Breakpoint

4.

a debugging technique that narrow the scope of the issues into manageable portions when faced with a complex problem

a)

Clustering Bugs

b)

Binary Search

c)

Log Analysis

d)

Breakpoints

5.

A debugging technique that is used to manually move through each line of code to study variables and data structures for problems.

a)

clustering bugs

b)

breakpoints

c)

stepping

d)

backtracking

6.

Articulating the problem out loud or written down forces critical thinking that can lead to discoveries of new insights and solutions. What do you call this debugging technique?

a)

clustering bugs

b)

log analysis

c)

Rubber Ducking

d)

backtracking

7.

An unexpected or error condition encountered in programming.

a)

Error Class

b)

Exception Handling

c)

exception

d)

exception class

8.

Refers to the object-oriented techniques that manage or resolve such errors.

a)

exception handling

b)

debugging

c)

rubber ducking

d)

object-oriented programming

9.

what is it called If an unplanned exception occurs during a program’s execution

a)

exception class

b)

syntax error

c)

runtime error

d)

error class

10.

what is it called, if an error is discovered during program compilation

a)

syntax error

b)

compile error

c)

error class

d)

build error

11.

It represents more serious errors that a program usually might not recover from.

a)

runtime error

b)

error class

c)

clustering bugs

d)

exception class

12.

it represents less serious errors that indicate unusual conditions that arise while a program is running and from which the program can recover.

a)

exception class

b)

files class

c)

path class

d)

error class

13.

The Error and Exception classes descend from what class?

a)

objects class

b)

Throwable class

c)

classes and objects

d)

exception class

14.

Is considered the superclass for all errors and exceptions in the Java language.

a)

OOP

b)

Throwable class

c)

Object class

d)

exception class

15.

the base class for exceptions thrown while accessing data from files, directories, and streams.

a)

IOException

b)

RuntimeException

c)

ArithmeticException

d)

InputMismatchException

16.

an exception that is only detected during the execution of the application.

a)

IndexOutOfBoundsException

b)

VirtualMachineError

c)

RuntimeException

d)

ArithmeticException

17.

Question 17

4 lines
18.

This is raised whenever a wrong mathematical operation appears in the code during runtime.

a)

ArithmeticException

b)

RuntimeException

c)

IOException

d)

InputMismatchException

19.

This exception is thrown when an index used in arrays, lists, or strings is invalid.

a)

IndexOutOfBoundsException

b)

ArrayIndexOutOfBoundsException

c)

ArrayIndexOutOfBoundsException

d)

OutOfMemoryError

20.

Indicates that an array has been accessed with an illegal index, either negative or greater than or equal to the size of the array.

a)

NoSuchElementException

b)

ArrayIndexOutOfBoundsException

c)

ArithmeticException

d)

IndexOutOfBoundsException

21.

Indicates that the element being requested does not exist.

a)

ArrayIndexOutOfBoundsException

b)

VirtualMachineError

c)

NoSuchElementException

d)

InputMismatchException

22.

Occurs when the user does not provide the proper type of input or input is out of range.

a)

ArrayIndexOutOfBoundsException

b)

VirtualMachineError

c)

NoSuchElementException

d)

InputMismatchException

23.

Indicates that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.

a)

InternalError

b)

VirtualMachineError

c)

OutOfMemoryError

d)

error class

24.

It is thrown when there is insufficient space to allocate an object.

a)

InsufficientError

b)

InternalError

c)

VirtualMachineError

d)

OutOfMemoryError

25.

It indicates unexpected internal error has occurred in the Java Virtual Machine.

a)

OutOfMemoryError

b)

RuntimeException

c)

IOException

d)

InternalError

26.

If a program ended prematurely with an error.

(a)  

27.

The list of error messages, which shows each method called as the program ran after each attempted execution

a)

log analysis

b)

crash

c)

VirtualMachineError

d)

stack trace

28.

This is placed when a programmer creates a segment of code in which something might go wrong.

a)

try block

b)

throw statement

c)

finally block

d)

catch block

29.

A segment of code that handles an exception that might be thrown by the try block that precedes it.

a)

try block

b)

finally block

c)

exception block

d)

catch block

30.

Sends an Exception object out of a block or method so it can be handled elsewhere.

(a)  

31.

It takes an argument that is some type of Exception. But it is not a method since it has no return type, and it cannot be called directly.

a)

finally block

b)

catch block

c)

constructor

d)

try block

32.

A block of code that executes whether or not the preceding try block identifies an Exception.

a)

try block

b)

throw statement

c)

catch block

d)

finally block

33.

Usually, this is used to perform cleanup tasks that must happen regardless of whether any Exceptions occurred or whether any Exceptions that occurred were caught.

a)

try block

b)

finally block

c)

stack trace

d)

catch block

34.

A collection of data stored on a nonvolatile device or a permanent storage device.

a)

file

b)

folder

c)

database

d)

drive

35.

This contain data that can be read in a text editor as the data is encoded using a scheme (ASCII or Unicode).

a)

data file

b)

text file

c)

binary file

d)

program files

36.

This contain data items that have not been encoded as text. The file’s contents are in binary format (0s and 1s)

a)

Binary files

b)

data files

c)

application files

d)

text files

37.

it is A complete list of the disk drive and the hierarchy of directories in which a file resides

a)

path

b)

directory

c)

path class

d)

computer file

38.

The backslash in the Windows operating system, that separates the path components.

a)

backslash (\)

b)

forward slash (/)

c)

colon (:)

d)

semicolon (;)

39.

Which is used as the delimiter in the Solaris (UNIX) operating system?

a)

asterisk ( * )

b)

C:\

c)

backslash ( \ )

d)

slash ( / )

40.

Which of the following are the operations you can do with files?

a)

writing & playing a file

b)

closing & posting a file

c)

deleting & scribbling a file

d)

Opening & Reading a file

41.

This creates objects containing information about files and directories, including their locations, sizes, creation dates, and whether they exist.

a)

Computer files

b)

Files Class

c)

FileSystems

d)

Path class

42.

This performs operations on files and directories, including deletion, determining their attributes, and creating input and output streams.

a)

Computer files

b)

Files Class

c)

FileSystems

d)

Path class

43.

What package is imported to use both the Path and Files classes?

a)

java.nio.file.*;

b)

java.nio.file.Paths;

c)

static java.nio.file.AccessMode.*;

d)

java.io.*;

44.

In object-oriented programming (OOP), this is an object that creates other objects.

a)

BasicFileAttributes

b)

factory

c)

Path

d)

FileSystem

45.

A complete path that does not need any information to locate a file on a system.

a)

Paths.get()

b)

Path class

c)

absolute path

d)

relative path

46.

An incomplete path that depends on other path information.

a)

absolute path

b)

relative path

47.

What method is used to convert a relative path to an absolute path?

a)

AbsolutePath()

b)

toAbsolutePath()

c)

getDefault()

d)

getPath()

48.

Returns the String representation of the path, eliminating double backslashes.

a)

toString()

b)

getFileName()

c)

getNameCount()

d)

getName(int)

49.

Returns the file or directory denoted by this Path

a)

toString()

b)

getFileName()

c)

getName(int)

d)

getNameCount()

50.

Returns the number of name elements in the Path

a)

getName(int)

b)

toString()

c)

getFileName()

d)

getNameCount()

51.

Returns the name in the position of the Path specified by the integer parameter

a)

getFileName()

b)

getNameCount()

c)

toString()

d)

getName(int)

52.

The method is used to verify that a file exists and that the program can access it as needed.

a)

checkAccess()

b)

provider()

c)

toString()

d)

getPath()

53.

Which is the correct import statement to be used to access constants that can be used as arguments in the method checkAccess()

a)

import static java.nio.file.AccessMode.*;

b)

import java.nio.file.*;

c)

import java.nio.file.attribute.*;

d)

import java.io.IOException;

54.

An argument of checkAccess(), which checks that the file exists and the program has permission to read the file

a)

EXECUTE

b)

WRITE

c)

READ

d)

EXISTS

55.

it is an argument of checkAccess(), which checks that the file exists and the program has permission to write to the file

a)

READ

b)

WRITE

c)

EXISTS

d)

EXECUTE

56.

A checkAccess() argument which checks that the file exists and the program has permission to execute the file

a)

EXISTS

b)

WRITE

c)

EXECUTE

d)

READ

57.

A method of the Files class can retrieve useful information about a file.

a)

readAttributes()

b)

FileSystems.get()

c)

lastModifiedTime()

d)

creationTime()

58.

a method used to return the size of a file in bytes.

a)

creationTime()

b)

size()

c)

lastModifiedTime()

d)

getSize()

59.

An abstract class that contains methods for performing input

a)

BufferedWriter

b)

OutputStream

c)

FileInputStream

d)

InputStream

60.

Child of InputStream that provides the capability to read from disk files

a)

FileInputStream

b)

OutputStream

c)

PrintStream

d)

BufferedReader

61.

Child of FilterInputStream that handles input from a system’s standard (or default) input device, usually the keyboard

a)

PrintStream

b)

BufferedReader

c)

FileInputStream

d)

BufferedInputStream

62.

An abstract class that contains methods for performing output

a)

BufferedOutputStream

b)

OutputStream

c)

PrintStream

d)

BufferedWriter

63.

Child of OutputStream that allows writing to disk files

a)

PrintStream

b)

OutputStream

c)

BufferedWriter

d)

BufferedOutputStream

64.

Child of FilterOutputStream that handles output from a system’s standard (or default) output device, usually the monitor

a)

BufferedOutputStream

b)

FileOutputStream

c)

BufferedWriter

d)

PrintStream

65.

Child of FilterOutputStream. Java’s System class contains a PrintStream object named System.out

a)

PrintStream

b)

BufferedReader

c)

FileOutputStream

d)

BufferedOutputStream

66.

Abstract class for reading character streams

a)

BufferedReader

b)

FileInputStream

c)

Reader

d)

BufferedWriter

67.

Reads text from a character-input stream, buffering characters to provide for efficient reading of characters, arrays, and lines

a)

BufferedInputStream

b)

PrintStream

68.

Writes text to a character-output stream, buffering characters to provide for the efficient writing of characters, arrays, and lines

a)

BufferedWriter

b)

BufferedReader

c)

FileOutputStream

d)

PrintStream

69.

the OutputStream method that Closes the output stream and releases any system resources associated with the stream

a)

flush()

b)

write(byte[] b)

c)

close()

70.

the OutputStream method that Flushes the output stream; if any bytes are buffered, they will be written

a)

flush()

b)

write(byte[] b)

c)

close()

71.

the OutputStream method that Writes all the bytes to the output stream from the specified byte array

a)

write(byte[] b)

b)

flush()

c)

close()

72.

The OutputStream method that writes bytes to the output stream from the specified byte array starting at offset position off for a length of len characters:

a)

flush()

b)

write(byte[] b, int off, int len)

c)

close()

d)

write(byte[] b)