ITP 120 - Chapter 11 QUIZ

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The exception classes are in packages in the ________.

Java API

The try statement may have an optional ________ clause, which must appear after all of the catch clauses.

finally

The following catch statement can: catch (Exception e) {...}

handle all exceptions that are instances of the Exception class or a subclass of Exception

The ability to catch multiple types of exceptions with a single catch is known as ________, and was introduced in Java 7.

multi-catch

In a try/catch construct, after the catch statement is executed:

the program resumes at the statement that immediately follows the try/catch construct

In a multi-catch, (introduced in Java 7) the exception types are separated in the catch clause by this symbol:

|

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);

0

If, within one try statement you want to have catch clauses of the following types, in which order should they appear in your program: (1) Exception (2) IllegalArgumentException (3) RuntimeException (4) Throwable

2, 3, 1, 4

If, within one try statement you want to have catch clauses that catch exceptions of the following types, in which order should they appear in your program? (1) Throwable (2) Exception (3) RuntimeException (4) NumberFormatException

4, 3, 2, 1

The catch clause:

All of these

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

Exception

In a catch statement, what does the following code do? System.out.println(e.getMessage());

It prints the error message for an exception.

The numeric classes' "parse" methods all throw an exception of this type if the string being converted does not contain a convertible numeric value.

NumberFormatException

All exceptions are instances of classes that extend this class.

Throwable

If the code in a method can potentially throw a checked exception, then that method must:

either handle the exception or have a throws clause listed in the method header

A(n) ________ is an object that is generated in memory as the result of an error or an unexpected event.

exception

Classes that inherit from the Error class are:

for exceptions that are thrown when a critical error occurs, and the application program should not try to handle them

An exception's default error message can be retrieved using this method.

getMessage()

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:

the first catch clause that can handle the exception.

If the program does not handle an unchecked exception:

the program is halted and the default exception handler handles the exception


Set pelajaran terkait

Nutrition Chapter 5: Carbohydrates

View Set