Filters
Question type

Study Flashcards

When an exception is thrown by code in the try block, the JVM begins searching the try statement for a catch clause that can handle it and passes control of the program to


A) the last catch clause that can handle the exception.
B) each catch clause that can handle the exception.
C) the first catch clause that can handle the exception.
D) the statement that appears immediately after the catch block.

Correct Answer

verifed

verified

To write data to a binary file, you create objects from the following classes:


A) File and Scanner.
B) BinaryFileWriter and BinaryDataWriter.
C) FileOutputStream and DataOutputStream.
D) File and PrintWriter.

Correct Answer

verifed

verified

In a try statement, the try clause must appear first, followed by all of the catch clauses, followed by the optional finally clause.

Correct Answer

verifed

verified

What will the following code display? String input = "99#7"; Int number; Try { Number = Integer.parseInt(input) ; } Catch(NumberFormatException ex) { Number = 0; } Catch(RuntimeException ex) { Number = 1; } Catch(Exception ex) { Number = -1; } System.out.println(number) ;


A) -1
B) 0
C) 1
D) 99

Correct Answer

verifed

verified

In Java, there are two categories of exceptions:


A) unchecked and checked.
B) runtime and compile-time.
C) critical and nominal.
D) static and dynamic.

Correct Answer

verifed

verified

When an object is serialized, it is converted into a series of bytes that contain the object's data.

Correct Answer

verifed

verified

True

Beginning in Java 7, you can use ________ to reduce a lot of duplicated code in a try statement that needs to catch multiple exceptions, but perform the same operation for each one.


A) multi-catch
B) catch templates
C) multi-try
D) catchAll

Correct Answer

verifed

verified

A

A class must implement the Serializable interface in order for objects of the class to be serialized.

Correct Answer

verifed

verified

This is a section of code that gracefully responds to exceptions when they are thrown.


A) exception
B) default exception handler
C) exception handler
D) thrown class

Correct Answer

verifed

verified

Unchecked exceptions are those that inherit from the


A) Error class or the RuntimeException class.
B) Error class or the Exception class.
C) Error class.
D) Exception Class or the RuntimeException class.

Correct Answer

verifed

verified

When an exception is thrown,


A) it must always be handled by the method that throws it.
B) it must be handled by the program or by the default exception handler.
C) it may be ignored.
D) the program terminates even if the exception is handled.

Correct Answer

verifed

verified

To read data from a binary file, you create objects from the following classes:


A) File and Scanner.
B) File and PrintWriter.
C) BinaryFileReader and BinaryDataReader.
D) FileInputStream and DataInputStream .

Correct Answer

verifed

verified

All of the exceptions that you will handle are instances of classes that extend this class.


A) IOException
B) Exception
C) Error
D) RunTimeException

Correct Answer

verifed

verified

When catching multiple exceptions that are related to one another through inheritance, you should handle the more specialized exception classes before the more general exception classes.

Correct Answer

verifed

verified

In order for an object to be serialized, the class must implement this interface.


A) Serial
B) Serializable
C) ObjectOutputStream
D) Writable

Correct Answer

verifed

verified

If a method does not handle a possible checked exception, what must the method have?


A) a try clause in its header
B) a catch clause in its header
C) a finally clause in its header
D) a throws clause in its header

Correct Answer

verifed

verified

If a class has fields that are objects of other classes, those classes must implement the Serializable interface in order to be serialized.

Correct Answer

verifed

verified

The throws clause causes an exception to be thrown.

Correct Answer

verifed

verified

The following catch clause Catch (Exception e)


A) can handle all throwable objects by using a polymorphic reference for the parameter.
B) can handle all exceptions that are instances of the Exception class or one of its subclasses.
C) can handle all exceptions that are instances of the Exception class, but not its subclasses.
D) causes a compiler error.

Correct Answer

verifed

verified

B

When using the throw statement, if you do not pass a message to the exception object's constructor,


A) the exception will have a null message.
B) the exception will have a message containing the address of the exception.
C) the exception will a default message describing the exception.
D) a compiler error will occur.

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer