Originally posted by John Mathew:
37. Which of the following statements about Java's garbage collection are true?
a) The garbage collector can be invoked explicitly using a Runtime object.
b) The finalize method is always called before an object is garbage collected.
c) Any class that includes a finalize method should invoke its superclass' finalize method.
d) Garbage collection behavior is very predictable.
to a)
-> No, you can only suggest JVM to run the gc.
to b)
-> No, it is not guaranteed that the finalize() method is called. (K&B,
SCJP 5, page 253)
to c)
-> I am not sure here, but I think this is correct, as finalize() is declared in the objet() class. Thinking twice it must be, because everything up the inheritance tree must be cleaned. It is vice versa of the constructor logic.
to d)
-> definitely not. You never know when it is going to run and what it going to do, besides cololecting garbage.
Good luck.