Posts

Showing posts from December, 2022

Core Java - Exceptions Handling

Image
What is an exception? An Exception is an unwanted event that  interrupts the normal flow of the program . When an exception occurs, program execution gets terminated. In such cases, we get a system generated error message. The good thing about exceptions is that java developer can handle these exceptions in such a way so that the program doesn’t get terminated abruptly and the user gets a meaningful error message. Why we use exception handling? or What is Exception Handling ? The core advantage of exception handling is  to maintain the normal flow of the application . An exception normally disrupts the normal flow of the application; that is why we need to handle exceptions. Let's consider a scenario: statement  1 ;   statement  2 ;   statement  3 ;   statement  4 ;   statement  5 ; //exception occurs    statement  6 ;   statement  7 ;   statement  8 ;   statement  9 ;   statement  10 ;   Suppose there are 10 statements in a Java program and an exception occurs at statement 5; the