JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java SE 討論區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友   
reply to postflat modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 請問一下關於garbage collection的問題
jenn





發文: 7
積分: 0
於 2003-08-27 23:22 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.

答案是C,F 請問一下為什麼呢?不是當makeThings() return的時候test物件變數reference的object就可以被gc了嗎?


reply to postreply to post
話題樹型展開
人氣 標題 作者 字數 發文時間
3917 請問一下關於garbage collection的問題 jenn 887 2003-08-27 23:22
5530 Re:請問一下關於garbage collection的問題 Duncan 7203 2003-08-28 14:46
3243 Re:請問一下關於garbage collection的問題 JiaYun 334 2003-08-28 15:08
3389 Re:請問一下關於garbage collection的問題 Duncan 463 2003-08-28 15:25
3142 Re:請問一下關於garbage collection的問題 popcorny 188 2003-08-28 15:47
3219 Re:請問一下關於garbage collection的問題 Duncan 306 2003-08-28 15:58
4248 Re:請問一下關於garbage collection的問題 Duncan 1071 2003-08-28 16:16
3118 Re:請問一下關於garbage collection的問題 jenn 189 2003-08-28 16:04
» JWorld@TW »  Java SE 討論區

reply to postflat modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8