Exception:- Exception is an error event that can occur during the execution of a program and it disrupts the normal flow of program. (e.g. divided by zero, array access out of bound, etc.). In Java, an exception is an object that wraps in error event and it occurred within a method and contains information about the error including its type.
The runtime system searches the call stack for a method. It contains a block of code that can handle the exception. This block of code is called an exception handler.
There are following reasons to occured an exception:-
- Users can entered invalid data.
- A network connection has been lost in the middle of communications or the JVM has run out of memory.
- To open file but file can not be found.
Exception handling class hierarchy:-