Originally posted by Siva Sivaraman:
The finalize() method is guaranteed to be called on any object to be GC�ed
True or False?
I'd say True -
this question is a little tricky ...
we know that
actual garbage collection is never
guaranteed when we make calls such as "Runtime.getRuntime.gc() or System.gc() however,
According to the book "Mike Meyer's Certification Passport
Java 2" written by
Glass,Griscti, Isayeva, Kallambella,
Sierra
(pg.129) "Every object inherits a finalize() method from java.lang.Object class.
The garbage collector is garunteed to invoke this method once prior to reclaiming the object's memory"
And another book "Java 2 Sun Certified Programmer Study Guide" 2nd Edition from Osborne states:
"Every class has a special method called a finalizer that is called just before an object is collected. The JVM calls the finalizer for you as appropriate; you never call a finalizer directly."