This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection

 
Saurabh V Vakil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case of inheritance, if the child class instance is garbage collected, then will the finalize method of the base class be called?
 
Daesung Park
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is called if subclass didn't override it.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, finalize() is an ordinary overridable method. So, if the subclass has a version of finalize(), then the superclass version will only be called if the subclass version calls super.finalize(). Normally, it should do so.

Of course, discussion of finalize() is of little more than academic interest, as there are very few worthwhile uses of finalisation.
 
Saurabh V Vakil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies guys!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic