- Base class of errors and Exceptions is Throwable class .
- finally block in Exception is always executed .
- finally block will not if program exits (System.exit(0); ) or causing a fatal error that causes the process to abort .
Exception Propagation :- It is used to forwarding the exception object to the invoking method is known as exception propagation .
Comparison between throw and throws :-
throw |
throws |
- it is used to explicitly throw an exception .
|
- It is used to declare an exception .
|
- checked exception cannot propagated with throw only.
|
- checked exception can be propagated with throws.
|
- throw is followed by an instance .
|
- throws is followed by class.
|
|
- It is used with the method signature .
|
|
- can declare multiple exceptions .(throws IOException , SQLException ) .
|
No comments:
Post a Comment