Posts

Showing posts from June, 2022

Exception Handling

Image
Agenda Introduction An unexpected unwanted event that disturbs normal flow of the program is called Exception. It is highly recommended to handle exceptions and the main objective of Exception handling is graceful termination of the program. Exception handling doesn't mean repairing an exception. We have to provide alternative way to continue rest of the program normally. This is the concept of Exception handling. Runtime stack mechanism For every thread JVM will create a runtime stack. Each and every method call performed by the thread will be stored in the corresponding stack. Each entry in the stack is called stack frame or activation record. After completing, every method call the corresponding entry from the stack will be removed. After completing all method calls, the stack will become empty and that empty stack will be destroyed by JVM just before terminating the thread. Default exception handling Exception hierarchy Customized exception handling by using try-catch Control f