14
Jun
A handler for an exception is found by propagating the exception backward through a chain of method calls, starting from the current method. Java’s exception-handling model is based on three operations: declaring an exception, throwing an exception, and catching an exception, as shown in figure below. Declaring Exceptions In Java, the statement currently being executed belongs to a method. The Java interpreter invokes the main method to start executing a program. Every method must state the types of checked exceptions it might throw. This is known as declaring exceptions. Because system errors and runtime errors can happen to any code,…