Organizational Research By

Surprising Reserch Topic

Question:Does the code in finally block get executed if there is an exception and a return statement in a catch block?

The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught. If an exception occurs and there is a return statement in catch block, the finally block is still executed. The finally block will not be executed when the System.exit(0) statement is executed earlier or on system shut down earlier or the memory is used up earlier before the thread goes to finally block.

//some statements
//statements when exception is caught
//statements executed whether exception occurs or not

asked Sep 13, 2013 in Core java by ashish singh
edited Sep 12, 2013
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.