GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 500 of 502    Print  
Exception on finalize ()?
If Exception occurs in finalize() what happened to garbage collector? It will run or not? Explain


  
Total Answers and Comments: 8 Last Update: November 18, 2009     Asked by: chinmayananda 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 18, 2009 11:22:53   #1  
maddy_me Member Since: September 2009   Contribution: 3    

RE: Exception on finalize ()?
Anyexception thrown by finalize() method during garbage collection will halts the finalization.
 
Is this answer useful? Yes | No
September 21, 2009 08:04:32   #2  
tmastanbabu Member Since: September 2009   Contribution: 1    

RE: Exception on finalize ()?
The program will go on and the object will be garbage collected.
 
Is this answer useful? Yes | No
September 29, 2009 11:24:55   #3  
coolpintu Member Since: September 2009   Contribution: 1    

RE: Exception on finalize ()?
When the garbage collector calls the finalize() method it will ignore any exceptions thrown by the finalize() method. In all other cases normal exception handling occurs when an exception is thrown during the execution of the finalize() method that is exceptions are not simply ignored. Calling the finalize() method does not in itself destroy the object.
 
Is this answer useful? Yes | No
October 21, 2009 04:34:40   #4  
yrk_in Member Since: October 2009   Contribution: 2    

RE: Exception on finalize ()?
There is no Guaranty execution of finalize() method because it will execute just before the garbage collected. But for every application Garbage collection will not be done.
when it will be collected we dont know.

 
Is this answer useful? Yes | No
October 21, 2009 05:48:07   #5  
ae8166558de88 Member Since: October 2009   Contribution: 3    

RE: Exception on finalize ()?
There is a finalizer thread which is a background thread and that has a runFinalizer method which skips all the exceptions thrown by invokeFinalizeMethod which internally calls the finalize method of Object to clean. That's why there is no impact on GC if finaliza throws the exception
 
Is this answer useful? Yes | No
October 23, 2009 07:43:36   #6  
sujoy_bec51 Member Since: October 2009   Contribution: 1    

RE: Exception on finalize ()?
If an uncaught exception is thrown during finalization the exception is ignored and finalization of that object terminates. This can leave the object in a corrupted state.
 
Is this answer useful? Yes | No
October 27, 2009 22:45:20   #7  
winoth4 Member Since: October 2009   Contribution: 4    

RE: Exception on finalize ()?
finalize() method is called when an object is removed from the memory in order to perform any clean up code like closing a file or stream...
 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
November 17, 2009 22:51:14   #8  
sampatkhurana Member Since: November 2009   Contribution: 1    

RE: Exception on finalize ()?
Any of the exception does not have effect of finalize method. The Portion of finalize method will do his work if any of the exception occur.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape