Chapter 6 - Exceptions Flashcards

1
Q

Runtime exceptions are also known as?

A

Runtime exceptions are also known as Unchecked exceptions.

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

Is a Runtime exception a subclass of RuntimeException?

A

Yes.

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

Is a Checked exception a subclass RuntimeException?

A

No. It is a subclass of Exception but not a subclass of RuntimeException.

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

What is the subclass of the Error type?

A

Subclass Error is the subclass of the Error type.

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

Are run time exceptions okay for a program to catch?

A

Yes, this applies to Runtime exception ans Checked exceptions.

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

Is a program requiered to handle or declared runtime exceptions?

A

No.

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

Is a program requiered to handle or declared checked exceptions?

A

Yes.

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

Is a program requiered to handle or declared Error?

A

No.

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

Do try statements require curly braces?

A

Yes. Try statements must have curly braces even if there is just one statement inside the code block.

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

Is catch neede after a try statement?

A

Yes, try must be always acompanied by a catch, otherwise the code will not compile.

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

Can finally blocks be used as part of try statements?

A

Yes. A finally block can only appear as part of a try statement.

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

Do finally blocks execute even if an exception in the try block does nos occur?

A

Yes. The finally block always executes whether or not an exception occurs in the try block.

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

Do a try statement must have catch and/or finally statements?

A

A try statement can have both: catch or finally. Having both is ok. No having any of those is a problem.

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

What will happen with a finally block if the System.exit method is called in the try or catch block?

A

If the System.exit method is called in a try or catch block, finally does not run.

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

Which type of exception is thrown When a superclass exception is caught before a subclass exception?

A

A compiler error about unreachable code occurs.

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