Chapter 6: Exceptions Flashcards

1
Q

What is true of all checked exceptions?

A

They are not subclasses of RuntimeException

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

T or F. Error is a subclass of Exception

A

False. It is a subclass of Throwable with Exception as a sibling

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

What is a checked exception?

A

An exception that must be handled or declared in order for the code to compile

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

T or F. A try block doesn’t require a catch block

A

True. A try block requires at least on catch or finally block

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

T or F. A try block can have multiple finally blocks

A

False

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

What happens when multiple exceptions are thrown?

A

Only the last one matters and is passed on

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

What kind of exception is ArithmeticException?

A

Runtime

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

What kind of exception is ArrayIndexOutOfBoundsException?

A

Runtime

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

What kind of exception is ClassCastException?

A

Runtime

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

What kind of exception is IllegalArgumentException?

A

Runtime

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

What kind of exception is NullPointerException?

A

Runtime

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

What kind of exception is NumberFormatException?

A

Runtime

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

What kind of exception is FileNotFoundException?

A

Checked

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

What kind of exception is IOException?

A

Checked

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

When must the caller handle an exception?

A

When a method declares that it throws a checked exception

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

T or F. When overriding a method that throws an exception, the child method doesn’t need to throw an exception

A

True

17
Q

T or F. A method can declare an exception even if nothing in it’s body can generate that exception

A

True

18
Q

T or F. If a RuntimeException is declared, it must be handled?

A

False. They are exempt from the checked exception rules