Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finalize

 
hari kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.if I catch an exception in the finalize method, then the object will be garbage collected?
2.if I don't catch the exception thrown in finalize() then the object is not garbage collected, but remains elligible for garbage collection?
Are these stmts T?
Pls explain
 
Umesh Joglekar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a quote from M & R
"A finalizer can catch and throw exceptions like other methods. However, any exception thrown but not caught by the finalizer when invoked by the garbage collector is ignored. The finalizer is only called once on an object, regrdless of being interrupted by any exception during its execution, In case of finalization failure the object still remains eligible to be disposed of at the discretion of the garbage collector(unless it has been resurrected)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic