Chapter 11 Review Flashcards

1
Q

What is an exception?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Exception Handling

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What elements are included in an exceptions stack trace?

A

name of exception
method stack call
time of exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Throw Point

A

The point in the program where an exception occurred

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What kind of block must come directly after a try block

A

catch or finally block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List five kinds of common exceptions

A
Array Out of Bounds
Memory Exhausted
Division by Zero
Arithmetic Overflow
Invalid Method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a resource leak?

A

This occurs when a program does not properly release a resource

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

If an exception is thrown during the execution of the throw block, which line of code executes next?

A

The line of code within the throw block associated with the exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Should a conventional application catch Error objects?

A

No, an Error indicates that a serious failure has occurred

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

The first matching catch block is executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Why should a programmer specify a superclass type as the type in a catch block?

A

This enables a program to catch related types of exceptions so they may be processed uniformly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the key reason for the finally block?

A

to prevent resource leaks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens when catch block throws an exception?

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the statement throw exceptionReference do in the catch block?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

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

A

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