Monday, April 30, 2007

What is finally in Exception handling?

'finally' is a part of try-catch-throw and finally blocks for exception handling mechanism in Java.'finally' block contains snippet which is always executed irrespective of exception occurrence. The runtime system always executes the statements within the finally block regardless of what happens within the try block. The cleanup code is generally written in this part of snippet e.g. dangling references are collected here.

1 comments :

Anonymous said...

One point to add... if you call exit in try or catch, JVM will exit immediately without executing finally block.

 

Disclaimer
Interview Questions On Java,Java EE Copyright © 2016. Reads: best tracker