Practice mode Java

Two Java objects refer only to each other and no live thread can reach either one. What is true of them?

Correct answer A. Both are eligible for garbage collection

Explanation

The Java collector works from reachability and not from simple reference counts, so a cycle that is unreachable from live threads is garbage just like a single unreachable object. The tempting answer describes pure reference counting, which leaks cycles. The objects may be reclaimed whenever the collector runs, with no explicit call required.

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.