SCJP中的一题(关于回收)
来源:互联网 发布:aes密码本算法 编辑:程序博客网 时间:2024/04/30 08:46
class TestA {
TestB b;
TestA() {
b = new TestB(this);
}
}
class TestB {
TestA a;
TestB(TestA a) {
this.a = a;
}
}
class TestAll {
public static void main (String args[]) {
new TestAll().makeThings();
// ...code continues on
}
void makeThings() {
TestA test = new TestA();
}
}
Which two statements are true after line 15, before main completes? (Choose two)
A. Line 15 causes a stack overflow.
B. An exception is thrown at runtime.
C. The object referenced by a is eligible for garbage collection.
D. The object referenced by b is eligible for garbage collection.
E. The object referenced by a is not eligible for garbage collection.
F. The object referenced by b is not eligible for garbage collection.
答案是c,d。它是这样解释的:This is a typical example of the island of isolation. On line 15, the two objects TestA and TestB have a eference to one an other. Therefore, the correct answers are C. and D. A key point to remember is that an object that is referenced by another object can be eligible for
garbage collection if the two objects form an island of isolated objects.
- SCJP中的一题(关于回收)
- 一道scjp的题:垃圾回收
- 关于 SCJP 1.4 考试
- 关于 SCJP 1.4 考试
- 关于 SCJP 1.4 考试
- 关于SCJP考试
- SCJP笔记一
- scjp题目解析(一)
- SCJP 笔记(一)
- SCJP试题一
- SCJP考题中的陷阱
- SCJP考题中的陷阱
- SCJP试卷中的Comment
- scjp考题中的陷阱
- 关于java虚拟机中的垃圾回收机制
- scjp考题中的种种陷阱
- scjp的模拟题
- scjp卡壳题
- 我要好好学习数据结构与算法
- 个性化Google主页
- .net常用代码1
- .net 2
- .net 3
- SCJP中的一题(关于回收)
- .net 4
- 什么是算法及其特征
- .net 5
- 遭遇“灰鸽子”
- 重享双休日的感觉
- 告白了
- ASP函数大全
- uml问题(个人学习):