Question - Does the code in finally block get executed if there is an exception and a return statement in a catch block?
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.