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.
Answer checked How we write and check questions
Discussion