1.
Given:
12. void start() {
13. A e = new A();
14. B b = new B();
15. a.s(b);
16. b = null;
17. a = null;
18. System.out.printIn(“start completed”);
19. }When is the B object, created in line 14, eligible for garbage collection?
A. After line 16.
B. After line 17.
C. After line 18 (when the methods ends).
D. There is no way to be absolutely certain.
E. The object is NOT eligible for garbage collection.各位朋友觉得这道题该选什么啊???2.
Given:
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? (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.
Answer: C, F.我个人认为应该选C,D啊~~~请达人给解释一下啊~~~~不好意思,认证区人气实在不行啊~~~我的帖子挂了好久连个人影都没看到~~~还请各位论坛朋友一起帮帮忙啊~~~3Q了