Thursday, March 12, 2009

Does the code in finally block get executed if there is an exception and a

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

Answer :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(1) statement is executed earlier or the system shut down
earlier or the memory is used up earlier before the thread goes to finally
block.

No comments: