Big Data and Hadoop Training @$80 or Rs. 6,000 only - valid till Oct 17th Apply Now!

When finally block is not executed in Java?

Ads
 

When finally block is not executed in Java?

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

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









Related Tutorials/Questions & Answers:
Example to show Finally exception in java
finally block
Advertisements
try and finally block
Finally in java
closing connections in finally block
The finally Keyword
difference between java5 and java6 - Java Beginners
Java2
about java1
Javah
javaa swings - IDE Questions
Java finally
About Java2
finally in flex
Javap Tool application
Artifacts of javax
Finally() in Java
Javah -  Header File Generator
Java try, catch, and finally
javax - JSP-Servlet
Javac -source KeyTest.java
the business logic is executed.
Version of javax>javaee-api dependency
Statement block
java.lang.NoClassDefFoundError: javax/transaction/UserTransaction????? - Struts
javax servlet error - JSP-Servlet
The else Keyword
Java Function for block inside a block
Java Function for block inside a block
Version of javax>javaee-endorsed-api dependency
Version of javax>javaee-web-api dependency

Ads