Flashcards in Chapter 11 Review Deck (16):
What is an exception?
An exception is an indication of a problem that occurs during a program's execution
A mechanism that allows programmers to create applications that can resolve exceptions
What elements are included in an exceptions stack trace?
name of exception
method stack call
time of exception
The point in the program where an exception occurred
A try block encloses code that might thrown an exception. All of its code must execute even if there is an exception.
the try block contains code that might throw and exception and code that should not execute if the exception occurs. The try blocks execution will stop when a exception is thrown
What kind of block must come directly after a try block
catch or finally block
List five kinds of common exceptions
Array Out of Bounds
Division by Zero
What is a resource leak?
This occurs when a program does not properly release a resource
If an exception is thrown during the execution of the throw block, which line of code executes next?
The line of code within the throw block associated with the exception
Should a conventional application catch Error objects?
No, an Error indicates that a serious failure has occurred
What happens if several catch blocks match the type of thrown object?
The first matching catch block is executed.
Why should a programmer specify a superclass type as the type in a catch block?
This enables a program to catch related types of exceptions so they may be processed uniformly.
What is the key reason for the finally block?
to prevent resource leaks
What happens when catch block throws an exception?
Control passes to the finally block if one exists. Then the exception will be processed by a catch block associated with an enclosing try block(if one exists)
What does the statement throw exceptionReference do in the catch block?
It re-throws the exception for processing by an exception handler of an enclosing try statement, after the finally block of the current try statement executes.