Which statement is true?
A. A class's finalize() method CANNOT be invoked explicitly.
B. super.finalize() is called implicitly by any overriding finalize() method.
C. The finalize() method for a given object is called no more than once by the garbage collector.
D. The order in which finalize() is called on two objects is based on the order in which the two objects became finalizable.
Answer: C
Explanation:
A is false because there is no restriction about invoking finalize().
B is false because the call to super.finalize() is not implicit.
C is true because the garbage collector cannot call twice the finalize() method on the same object. It can only be called once on an object, and it only gets called by the garbage collector after an object is eligible for garbage collection, but before the object is
actually garbage collected.
D is false because the order cannot be predicted.
No comments:
Post a Comment