- 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)c d 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
这是一个典型的孤立岛屿的例子。要记住:一个对象,它是由另一个对象引用可以有资格
垃圾收集,如果是两个对象则构成孤立的对象岛。
:D 什么是垃圾收集? :wink: