Exceptions Flashcards

1
Q

Checked vs. unchecked exceptions. Why would one use former or later?

A

Checked - need to handle
Unchecked - no need

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

Difference in Error and UncheckedException

A

error - should not try to catch
exchecption - might want to catch

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

Could we have only try and finally without catch

A

yes

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

Cases when the finally block isn’t executed

A

system exit 0
exception in finally

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

How to avoid catch block?

A

either catch or finally must follow try block

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

What is Suppressed exception?

A

suppression happens (automatically) only to exceptions that are thrown in a try-with-resources
the suppressed exception is recorded in the original exception

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

What is try-with-resources ?

A

ensures that each resource is closed at the end of the statement execution

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