后天就要考scjp了。有个问题急!
请教!!不是说对象为空的时候就可以收集了吗, 着是035的几道题 。
1.public class X(
2.public Object m(){
3.object o=new float(3.15F);
4 Object []oa=new object[1];
5. oa[0]=o;
6. o=null;
7. return oa[0];
8.}
9.}
when is the float Object created in line 3,eligible for
garbage collection?
A.Just after line 5
B.Just after line 6
C.Just after line 7(that is ,as the mothed returns)
D.Never in the Method .
Answer :D
12.void start(){
13.A a=new A();
14.B b=new B();
15.a.s(b);
16.b=null;
17.a=null;
18.System.out.print("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 mothed ends)
D.There is no way to be absolutely certain.
E.The Object is NOT eligible for garbage collection
Answer:C
10.public Object m(){
11.Object o=new Float(3.14F);
12.Object []oa=new Object[1];
13.oa[0]=o;
14.o=null;
15.oa[0]=null;
16.return 0;
17.}
When is the Float Object ,created in line 11,eligible for
garbage collection ?
A.Just after line 13.
B.Just after line 14.
C.Just after line 15.
D.Just after line 16(that is as the Method returns).
Answer:B