wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception handling" Watch "Exception handling" New topic
Author

Exception handling

manasa teja
Ranch Hand

Joined: May 27, 2002
Posts: 325
Is there any exception case to the following statement?
In a try-catch-finally construct, if a finally block is present, then it is guaranteed to be executed.
-thanks
Murthy


MT
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
If the program were to terminate prior to that, the finally block would not be exeucted.
Take this example:

Corey


SCJP Tipline, etc.
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Also, if an exception is thrown inside the finally block and is not caught within the same scope, the exception will propagate outwards and the finally block will not complete its execution.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Only if you call System.exit before the flow reaches the finally block.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception handling
 
Similar Threads
try and catch
Execution of finally
exception thrown in finally
Try Catch Finally - Voodoo Question