•An exception is an object that is thrown from the site of an error and can be caught by an appropriate exception
handler.
•Separating the handler from error
detection makes the code easier to read and write. finally
clause helps cleanup.
•User-defined exceptions can be created
or thrown. They are normally not caught in the same block, but passed up
to a calling
block. For e.g.,
• throw new NullPointerException();
•The try
region is a guarded region from which errors can be caught by
exceptions. Code that good generate an exception is enclosed in a try region. Method is exited if exceptions
are
thrown from outside try regions.
Thus, there is more reliable error recovery without simply exiting.
•It is also possible to rethrow exceptions.