15 Exception Handling
Exceptions in Java are objects. All exceptions are derived from the java.lang.Throwable class. Exceptions can be handled in Java using the try-catch-finally construct. Exceptions thrown by the try block of code are caught (handled) by the catch block. The following code shows an example of the try-catch-finally construct. The output of the above example Whenever an exception is thrown by try block of code, it looks for catch construct which handles that exception. If no catch construct is found which handles the exception, then the exception is handled by the default exception handler. The catch construct is not executed if…