aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes gc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "gc" Watch "gc" New topic
Author

gc

peter kens
Greenhorn

Joined: Jul 15, 2002
Posts: 4
Hi,
I am confused with finalize() chaining given in Mughals page 253, can you anyone give me simple example of finalize() chaining
Thank you very much
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

So.... Constructor's are impliclitly chained -- when you create a constructor, if you don't specifically call super() or this() -- then super() will implicitly be called. (If you need more information about this --- check out page 192 in Mughal's)
However, Finalizers are not implicitly chained. Because of this -- you "should explicitly call the finalizer in its super class as its last action." -- that way whatever things the superclass cleans up during its finalizer method, will get done for the subclass as well.
Does that help? What exactly are you confused about?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
As Jess said - you finalizers don't chain implicitly like constructors do. When you instantiate an object, the constructor of that class, along with all of its superclasses is invoked. This is not true when it comes to finalization.
It is not required that a superclass be finalized prior to a subclass in the way that a superclass must be initialized prior to a subclass. Thus, there is no implicit invocation of the superclass' finalization method.
It is good practive, however, to invoke it yourself, as Jess mentioned.
Corey


SCJP Tipline, etc.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: gc