+ 1
What will happen if you put return statement or System.exit () on try or catch block? Will finally block execute? Read more: ht
. This question challenge that concept by putting a return statement in the try or catch block or calling System.exit() from try or catch block
2 Answers
+ 2
just return; statement from a method will goes to execute finally block. comes out of method..
And should write it properly..
But System.exit(0);
Stops Program execution without finally executed...
Try it in playground......
Except by the system calls, finally block executed..
0
+ similar situation if catch() throw Exception then finally will even be executed before throw