Tuesday, October 27, 2015

Core Java - What will happen if you call return statement or System.exit on try or catch block ? will finally block execute?



This is a very popular tricky Java question and its tricky because many programmer think that finally block always executed. This question challenge that concept by putting return statement in try or catch block or calling System.exit from try or catch block. 

Answer of this tricky question in Java is that finally block will execute even if you put return statement in try block or catch block but finally block won't run if you call System.exit form try or catch.

No comments:

Post a Comment