Two of them are of type Beta : b1,b2
Two of them are of type Alpha : a1,a2
Look here, a2 is not null, so you can access its members b1 and b2 ( those which were created above using new )
[a2.b1 is same as a1.b1, since class alpha's b1 is static ]
Now it is clear that, you can access a2,b1 and b2 but you cant access a1 and that is eligible for GC.
Try it with paper and pen digramatically,
SCJP 6 with 80%, going for SCWCD
Aakash Goel
Ranch Hand
Joined: May 26, 2008
Posts: 198
posted
0
see the image attached... its a bit hazy though.
X -> reference that have been nulled
boxes -> the objects
so the object originally referred by a1 can now not be reached, all others can be reached through a2.