Chapter 11 Review Flashcards Preview

COP_3252 > Chapter 11 Review > Flashcards

Flashcards in Chapter 11 Review Deck (16):
1

What is an exception?

An exception is an indication of a problem that occurs during a program's execution

2

Exception Handling

A mechanism that allows programmers to create applications that can resolve exceptions

3

What elements are included in an exceptions stack trace?

name of exception
method stack call
time of exception

4

Throw Point

The point in the program where an exception occurred

5

A try block encloses code that might thrown an exception. All of its code must execute even if there is an exception.

False

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

6

What kind of block must come directly after a try block

catch or finally block

7

List five kinds of common exceptions

Array Out of Bounds
Memory Exhausted
Division by Zero
Arithmetic Overflow
Invalid Method

8

What is a resource leak?

This occurs when a program does not properly release a resource

9

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

10

Should a conventional application catch Error objects?

No, an Error indicates that a serious failure has occurred

11

What happens if several catch blocks match the type of thrown object?

The first matching catch block is executed.

12

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.

13

What is the key reason for the finally block?

to prevent resource leaks

14

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)

15

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.

16

What happens to a local reference in a try block when that block throws and exception?

The reference is moved out of scope. The object is unreachable and is scheduled for garbage collection.