Ducking The Exception or Exception Propagation

Let me give you small example to understand “Ducking” the exception.
We know, methods are getting pushed to stack for execution. In the below picture:
main() method is calling method1()
method1() is calling method2()
method2() is calling method3()
Now imaging,
  1. A/An checked/unchecked exception occurred at method3().
  2. That exception is not either handled or declared at method3() block. Then the runtime system will try to popper from the stack and come back to method2().
  3. At method2() level, follow step:2
  4. At method1() level, follow step:2
  5. At main() level, follow step:2
  6. main() method will complete and JVM will exit and normal flow of the program is interrupted.\

 

ducking_of_exception
ducking of exception
For fixing this scenario, we need to understand “Handle” or “Declare” mechanism.

 

If you like the post then please socialize it. Happy Sharing. Loudly Subscribing.

Leave a Reply

Your email address will not be published. Required fields are marked *