Font size
WorksheetsJava Exceptions and Errors Worksheet
Total questions: 72
Worksheet time: 39mins
the process of identifying and rectifying errors in a program that leads to unexpected behavior
Exception Handling
Debugging
Rubber Ducking
Error Class
also known as backward debugging
Backtracking
Clustering Bugs
Stepping
Binary Search
the point in the code to temporarily stop the execution of the program to inspect the state of its functionality.
Stepping
Rubber Ducking
Binary Search
Breakpoint
a debugging technique that narrow the scope of the issues into manageable portions when faced with a complex problem
Clustering Bugs
Binary Search
Log Analysis
Breakpoints
A debugging technique that is used to manually move through each line of code to study variables and data structures for problems.
clustering bugs
breakpoints
stepping
backtracking
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?
clustering bugs
log analysis
Rubber Ducking
backtracking
An unexpected or error condition encountered in programming.
Error Class
Exception Handling
exception
exception class
Refers to the object-oriented techniques that manage or resolve such errors.
exception handling
debugging
rubber ducking
object-oriented programming
what is it called If an unplanned exception occurs during a program’s execution
exception class
syntax error
runtime error
error class
what is it called, if an error is discovered during program compilation
syntax error
compile error
error class
build error
It represents more serious errors that a program usually might not recover from.
runtime error
error class
clustering bugs
exception class
it represents less serious errors that indicate unusual conditions that arise while a program is running and from which the program can recover.
exception class
files class
path class
error class
The Error and Exception classes descend from what class?
objects class
Throwable class
classes and objects
exception class
Is considered the superclass for all errors and exceptions in the Java language.
OOP
Throwable class
Object class
exception class
the base class for exceptions thrown while accessing data from files, directories, and streams.
IOException
RuntimeException
ArithmeticException
InputMismatchException
an exception that is only detected during the execution of the application.
IndexOutOfBoundsException
VirtualMachineError
RuntimeException
ArithmeticException
Question 17
This is raised whenever a wrong mathematical operation appears in the code during runtime.
ArithmeticException
RuntimeException
IOException
InputMismatchException
This exception is thrown when an index used in arrays, lists, or strings is invalid.
IndexOutOfBoundsException
ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException
OutOfMemoryError
Indicates that an array has been accessed with an illegal index, either negative or greater than or equal to the size of the array.
NoSuchElementException
ArrayIndexOutOfBoundsException
ArithmeticException
IndexOutOfBoundsException
Indicates that the element being requested does not exist.
ArrayIndexOutOfBoundsException
VirtualMachineError
NoSuchElementException
InputMismatchException
Occurs when the user does not provide the proper type of input or input is out of range.
ArrayIndexOutOfBoundsException
VirtualMachineError
NoSuchElementException
InputMismatchException
Indicates that the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating.
InternalError
VirtualMachineError
OutOfMemoryError
error class
It is thrown when there is insufficient space to allocate an object.
InsufficientError
InternalError
VirtualMachineError
OutOfMemoryError
It indicates unexpected internal error has occurred in the Java Virtual Machine.
OutOfMemoryError
RuntimeException
IOException
InternalError
If a program ended prematurely with an error.
(a)
The list of error messages, which shows each method called as the program ran after each attempted execution
log analysis
crash
VirtualMachineError
stack trace
This is placed when a programmer creates a segment of code in which something might go wrong.
try block
throw statement
finally block
catch block
A segment of code that handles an exception that might be thrown by the try block that precedes it.
try block
finally block
exception block
catch block
Sends an Exception object out of a block or method so it can be handled elsewhere.
(a)
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.
finally block
catch block
constructor
try block
A block of code that executes whether or not the preceding try block identifies an Exception.
try block
throw statement
catch block
finally block
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.
try block
finally block
stack trace
catch block
A collection of data stored on a nonvolatile device or a permanent storage device.
file
folder
database
drive
This contain data that can be read in a text editor as the data is encoded using a scheme (ASCII or Unicode).
data file
text file
binary file
program files
This contain data items that have not been encoded as text. The file’s contents are in binary format (0s and 1s)
Binary files
data files
application files
text files
it is A complete list of the disk drive and the hierarchy of directories in which a file resides
path
directory
path class
computer file
The backslash in the Windows operating system, that separates the path components.
backslash (\)
forward slash (/)
colon (:)
semicolon (;)
Which is used as the delimiter in the Solaris (UNIX) operating system?
asterisk ( * )
C:\
backslash ( \ )
slash ( / )
Which of the following are the operations you can do with files?
writing & playing a file
closing & posting a file
deleting & scribbling a file
Opening & Reading a file
This creates objects containing information about files and directories, including their locations, sizes, creation dates, and whether they exist.
Computer files
Files Class
FileSystems
Path class
This performs operations on files and directories, including deletion, determining their attributes, and creating input and output streams.
Computer files
Files Class
FileSystems
Path class
What package is imported to use both the Path and Files classes?
java.nio.file.*;
java.nio.file.Paths;
static java.nio.file.AccessMode.*;
java.io.*;
In object-oriented programming (OOP), this is an object that creates other objects.
BasicFileAttributes
factory
Path
FileSystem
A complete path that does not need any information to locate a file on a system.
Paths.get()
Path class
absolute path
relative path
An incomplete path that depends on other path information.
absolute path
relative path
What method is used to convert a relative path to an absolute path?
AbsolutePath()
toAbsolutePath()
getDefault()
getPath()
Returns the String representation of the path, eliminating double backslashes.
toString()
getFileName()
getNameCount()
getName(int)
Returns the file or directory denoted by this Path
toString()
getFileName()
getName(int)
getNameCount()
Returns the number of name elements in the Path
getName(int)
toString()
getFileName()
getNameCount()
Returns the name in the position of the Path specified by the integer parameter
getFileName()
getNameCount()
toString()
getName(int)
The method is used to verify that a file exists and that the program can access it as needed.
checkAccess()
provider()
toString()
getPath()
Which is the correct import statement to be used to access constants that can be used as arguments in the method checkAccess()
import static java.nio.file.AccessMode.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.io.IOException;
An argument of checkAccess(), which checks that the file exists and the program has permission to read the file
EXECUTE
WRITE
READ
EXISTS
it is an argument of checkAccess(), which checks that the file exists and the program has permission to write to the file
READ
WRITE
EXISTS
EXECUTE
A checkAccess() argument which checks that the file exists and the program has permission to execute the file
EXISTS
WRITE
EXECUTE
READ
A method of the Files class can retrieve useful information about a file.
readAttributes()
FileSystems.get()
lastModifiedTime()
creationTime()
a method used to return the size of a file in bytes.
creationTime()
size()
lastModifiedTime()
getSize()
An abstract class that contains methods for performing input
BufferedWriter
OutputStream
FileInputStream
InputStream
Child of InputStream that provides the capability to read from disk files
FileInputStream
OutputStream
PrintStream
BufferedReader
Child of FilterInputStream that handles input from a system’s standard (or default) input device, usually the keyboard
PrintStream
BufferedReader
FileInputStream
BufferedInputStream
An abstract class that contains methods for performing output
BufferedOutputStream
OutputStream
PrintStream
BufferedWriter
Child of OutputStream that allows writing to disk files
PrintStream
OutputStream
BufferedWriter
BufferedOutputStream
Child of FilterOutputStream that handles output from a system’s standard (or default) output device, usually the monitor
BufferedOutputStream
FileOutputStream
BufferedWriter
PrintStream
Child of FilterOutputStream. Java’s System class contains a PrintStream object named System.out
PrintStream
BufferedReader
FileOutputStream
BufferedOutputStream
Abstract class for reading character streams
BufferedReader
FileInputStream
Reader
BufferedWriter
Reads text from a character-input stream, buffering characters to provide for efficient reading of characters, arrays, and lines
BufferedInputStream
PrintStream
Writes text to a character-output stream, buffering characters to provide for the efficient writing of characters, arrays, and lines
BufferedWriter
BufferedReader
FileOutputStream
PrintStream
the OutputStream method that Closes the output stream and releases any system resources associated with the stream
flush()
write(byte[] b)
close()
the OutputStream method that Flushes the output stream; if any bytes are buffered, they will be written
flush()
write(byte[] b)
close()
the OutputStream method that Writes all the bytes to the output stream from the specified byte array
write(byte[] b)
flush()
close()
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:
flush()
write(byte[] b, int off, int len)
close()
write(byte[] b)
