What happens when we have a return statement in the try block as well as in the finally block.?

When we have return statement both in try and finally blocks, then first the return statement of try block gets executed, the before the method returns, the statements in the finally block will get executed and since there is return statement in finally also, that will also get executed and the value that will be returned to the caller will be the value returned from the finally block.


Enter your email address to get our daily JOBS & INTERVIEW FAQ's Straight to your Inbox.

Make sure to activate your subscription by clicking on the activation link sent to your email