Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

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

0
Posted

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

0

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.

Thanksgiving questions

*Sadly, we had to bring back ads too. Hopefully more targeted.