Skip to main content

Posts

Showing posts with the label java

Exception Handling in Java

The term exception is shorthand for the phrase "exceptional event." Definition : An exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program's instructions.  When an error occurs within a method, the method creates an object and hands it off to the runtime system. The object, called an exception object, contains information about the error, including its type and the state of the program when the error occurred. Creating an exception object and handing it to the runtime system is called throwing an exception. After a method throws an exception, the runtime system attempts to find something to handle it.  Some of the predefined exception classes are :  ArithmeticException, ArrayIndexOutOfBoundException, IOException etc.