Lets assume that main() has called fun1(), which calls fun2(), which calls fun3(). And assume that fun3() has thrown some exception object to java run time system, now in which order java run time system will search for the exception handler?
it searches in below order. main, fun1, fun2, fun3
it searches in below order. fun3, fun2, fun1, main
it searches in the below order fun2, fun1, main
it searches only fun3.
If it did not find any exception handler till main function, then java run time system will forcefully close your application.
JRE checks for exception handlers (try-catch blocks) always in the revers order of the function call in stack trace, starting with current function.
Back To Top