WEEK 7-8: EXCEPTION HANDLING Flashcards

1
Q

Unexpected or error conditions

An abnormal condition that must be properly handled to prevent program termination

A

Exceptions

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

Causes of Exceptions

A

The program issues a call to a file that does not exist

The program attempts to write to a full disk

The user enters invalid data

The program attempts to divide a value by 0

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

Object-oriented techniques used to manage Exception errors

Runtime exceptions

A

Exception handling

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

Represents serious errors from which a program usually cannot recover

Error condition

A program runs out of memory

A program cannot locate a required class

A

Error class

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

Less serious errors

Unusual conditions

A program can recover from this type of error

A

Exception class

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

A segment of code in which something might go wrong

Attempts to execute

Acknowledges an exception might occur

A

Try block

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

A try block includes:

A

The keyword try
Opening and closing curly braces
Executable statements, which might cause an exception

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

A segment of code that immediately follows a try block

Handles an exception thrown by the try block preceding it

Can “catch” an Object of type Exception or an Exception child class

A

catch block

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

A catch block includes:

A

The keyword catch

Opening and closing parentheses

An Exception type

A name for an instance of the Exception type

Opening and closing curly braces

Statements to handle the error condition

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

Use for actions you must perform at the end of a try catch sequence

Use to perform cleanup tasks

Executes regardless of whether the preceding try block identifies an exception

A

finally block

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

When the try code fails:

A

It throws an exception

The Exception object is caught

The catch block executes

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

Reasons the final set of statements might never execute:

A

An unplanned exception might occur

The try or catch block might contain a System.exit(); statement

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

If the try block might throw an Exception object for which you did not provide a catch block:

A

Program execution stops immediately

The exception is sent to the operating system for handling

The current method is abandoned

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