Practice mode Java

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.