When does a Java object become eligible for garbage collection?
Correct answer D. When no live thread can reach it through references
Explanation
Eligibility depends on reachability. An object that cannot be reached by any continuing computation from a live thread may have its memory reclaimed. A method returning does not free an object that is still referenced elsewhere, for instance from a field. The collector chooses when to act, so eligibility never means immediate reclamation.
Answer checked How we write and check questions
Discussion