File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes what if a runtime exception happen inside a finalize method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what if a runtime exception happen inside a finalize method" Watch "what if a runtime exception happen inside a finalize method" New topic
Author

what if a runtime exception happen inside a finalize method

harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
What will happen if a runtime exception happen inside finalize method.

options are
a) application will break down
b) the object in finalize method will be released
c) the object will not be released
d) none of these


SCJP 1.5
"A candle looses nothing by lighting another candle"
itechmentors.com
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

this looks like a question from some test or book. We require you quote your source for anything you post here if it is not your original work.

thanks


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
dear friend...i got it from a question paper..of a recruitment exam..
i do remember the question paper series..QF1 and i think its not a good thing to say the company name


Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

well basically if you speak of finalize means the program created everything properly and JVM ran properly without exceptions. Also finalize is run for a object. So what type of object are they talking and reassigning it to a reference variable so that its not eligible for GC won't throw and exception. Basically i think there won't be any exceptions in a finalize. But if there are any exceptions is thrown then it will halt the finalization process that's all. Application won't break down. C is the appropriate answer here. Object won't be gc'd but is still elligible for GC. But next time it will be gc'd as finalize on the object just runs once.

[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
harilal ithikkat
Ranch Hand

Joined: Oct 06, 2008
Posts: 221
Thank you Nitish ...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what if a runtime exception happen inside a finalize method