可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

1. class TestA {&#8


1. class TestA {  2. TestB b;  3. TestA() {  4. b = new TestB(this);  5. }  6. }  7. class TestB {  8. TestA a;  9. TestB(TestA a) {  10. this.a = a;  11. }  12. }  13. class TestAll {  14. public static void main (String args[]) {  15. new TestAll().makeThings(); 16. // ...code continues on  17. }  18. void makeThings() {  19. TestA test = new TestA(); 20. }  21. }  Which two statements are true after line 15, before main completes?()

  • 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.
参考答案
参考解析:

This is a typical example of the island of isolation. On line 15, the two objects TestA and TestB have a reference 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程序员认证考试题库
相关推荐

1、若a=5,b=3,c=4,逻辑表达式!(a+b)&;&;!c的值

若a=5,b=3,c=4,逻辑表达式!(a+b)&;&;!c的值为()A0B-1C1D2

2、AMPS通信系统属于第()代移动通信。

AMPS通信系统属于第()代移动通信。A第一代B第二代C第三代D第四代

3、设N=44,M=55,K=”N+M”,表达式1+&K的值是( )。

设N=44,M=55,K=”N+M”,表达式1+&K的值是( )。AA)4456BB)100CC)1+M+NDD)数据类型不匹配

4、AMPS属于()。

AMPS属于()。A1GB2GC3GD4G

5、cAMP(cyclic AMP)

cAMP(cyclic AMP)

6、表达式10>5&&6%3的值是()

表达式10>5&&6%3的值是()A-1B非零值C0D1