Lecture 10 - Exceptions Flashcards
1
Q
Errors vs Exceptions
A
Errors are system errors, rare and difficult to repair.
Exceptions can/should be solved by programmer.
2
Q
Errors/Checked/Unchecked
A
- Errors should generally not be caught. Represent irrecoverable situations.
- Unchecked run-time exception should generally be caught, could be declared. Represent unexpected but recoverable situation.
- Checked run-time exception must be declared and must be caught. Represent recoverable situations.
3
Q
Syntax
A
There can be 0, 1 or more catch clauses since more than one exception type can be thrown or the exception is dealt with elsewhere.
4
Q
Why create own Exception Class?
A
Being Specific so you can handle exceptions effectively.
5
Q
Finally Clause
A
Optional, can be useful in cleaning up before the program terminates.