When finally block is not executed in Java?

 
 

Share on Google+Share on Google+

Java Coder
When finally block is not executed in Java?
1 Answer(s)      9 days ago
Posted in : Java Beginners
Ads

Hi,

I have read that finally block is always executed in Java. But I want to know if there is any conditions when finally is not executed.

When finally block is not executed in Java?

Thanks

Ads
View Answers

January 7, 2018 at 7:53 AM


Hi,

There are cases when finally block is not executed in Java program. Here are the cases when finally block is not executed:

  • If System.exit() called in the program.

  • When JVM crashes due to some reason.

  • If program is in non-terminating statement and it is stopped by killing the program

  • If OS kills Java process. In windows its through task manager. In linux its kill -9 command.

  • If there is system power faliure

Check Java tutorials.

Thanks


Ads









Ads

 
Advertisement null

Ads