Topic: A Question: (garbage collection)

  Print this page

1.A Question: (garbage collection) Copy to clipboard
Posted by: aleel_008
Posted on: 2004-10-03 10:44

class Demo {
  private Demo d;
  void start() {
    d = new Demo();
//    d.takeDemo(d);

  }

  void takeDemo(Demo demo) {
    demo = null;
    demo = new Demo();
  }
}
When is the Demo object created on line 3,eligible for garbage collection?
A.After line 5
B.After line 9
C After the start method completes
D When the takeDemo method completes
E.When the instance running this code is made is made eligible for garbage collecction
the answer is E.why B is incorrect and E is correct?

2.Re:A Question: [Re: aleel_008] Copy to clipboard
Posted by: elysium922
Posted on: 2004-10-03 11:46

It would be much easier for people to understand the question if you had indended the code properly with appropriate line numbers. Anyway, since you have commented out the call to takeDemo, I don't see any reason why E wouldn't be the answer.

3.Re:A Question: [Re: aleel_008] Copy to clipboard
Posted by: aleel_008
Posted on: 2004-10-03 12:24

I know the choiceE is correct ,but why is the choice B wrong?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923