This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Garbage collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Garbage collection" Watch "Garbage collection" New topic

Garbage collection

Saurabh V Vakil

Joined: Jan 30, 2008
Posts: 14
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

Joined: Mar 22, 2007
Posts: 68
Yes, it is called if subclass didn't override it.

Daesung Park

Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Saurabh V Vakil

Joined: Jan 30, 2008
Posts: 14
Thanks for your replies guys!!!
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Garbage collection
Similar Threads
string question
garbage collection problem
another finalize doubt
WA #1.....word association
GC and static variable.