I read a comment from Java 2 Exam Prep by Bill Brogden. he said "when extending a class that has a finalize method you MUST write a finalize that executes super.finalize()".

is it true? my compiler or VM did not compain about it.

Who is Participating?
AMD_MANConnect With a Mentor Commented:

Check out:

It states:
"The finalize method is a member of the Object class, which is the top of Java's class hierarchy and the parent of everything. A class can override the finalize method to perform any finalization necessary for objects of that type. If you override finalize, then your implementation of the method should call super.finalize as the last thing it does"

This only makes sense. If you are using finalize, possibly classes you inherit from may also use it.  This seems similar to the way destructors are called in C++.

The VM or compiler may not complain in your specific case.  But there may be situations out there where finalizing the super class is needed (the class closes a file/socket/whatever).

Good luck!
All Courses

From novice to tech pro — start learning today.