SCJP1.6 JAVA 6 CERTIFICATION Guide-310-065
by Katherine Sierra (Author), Bert Bates (Author)
pg-284
question-11
self test
OCPJP 6.0 93%
OCPJWCD 5.0 98%
SCJP 6.0 96%
(Connecting the Dots ....)
SCJP 6
OCPJP 6.0 93%
OCPJWCD 5.0 98%
1. when a1=Null,would its instance variables exist ? i.e
2.if the line a1.b2 = b1; is removed would still one object be available for GC ?
3.if Alpha class contains
Beta b1;
instead of
Static Beta b1;
then also would one object be available for GC ?
SCJP 6.0 96%
(Connecting the Dots ....)
ujjawal rohra wrote:When a1=null; b1=null; b2=null will execute only object referred to by a1
will be eligilble for GC.
b2 will not be eligible because b2 of a2 is pointing towards it(Line 14).
b1 will not be eligible because the static varable b1 of class Alpha objects is still
pointing to b1 (Line 12). Remeber static variable is shared by all the objects of
a class.
Therefore if you write a1.b1=b2 or a2.b1=b2 after line 12 then no object will
point towards b1 and then b1 will be eligible for GC but not now.
Hope this would help
![]()
Do you mean that b1 should be elegible for GC if you write a1.b1=b2 or a2.b1=b2 in line 12?.. but what about line 13 a1.b2=b1? We will find another reference in this line.
Consider Paul's rocket mass heater. |