您能解释一下这个答案吗?正如我预期的答案C有多少个物品可以使用gc
Given:
11. class Snoochy {
12. Boochy booch;
13. public Snoochy() { booch = new Boochy(this); }
14. }
15.
16. class Boochy {
17. Snoochy snooch;
18. public Boochy(Snoochy s) { snooch = s; }
19. }
And the statements:
21. public static void main(String[] args) {
22. Snoochy snoog = new Snoochy();
23. snoog = null;
24. // more code here
25. }
哪些声明对于第23行执行后立即引用的snoog,snooch和booch的对象是正确的?
A. None of these objects are eligible for garbage collection.
B. Only the object referenced by booch is eligible for garbage collection.
C. Only the object referenced by snoog is eligible for garbage collection.
D. Only the object referenced by snooch is eligible for garbage collection.
E. The objects referenced by snooch and booch are eligible for garbage collection.
Answer: E
闻起来像编码竞争:) – 2013-04-25 06:34:10
什么是停止'booch'被收集?我期望E. – 2013-04-25 06:35:49
你说答案是'C',但你发布的问题说答案是'E'。 – SudoRahul 2013-04-25 06:36:32