Vonique Leary wrote:I don't really understand the reference a1.b1 = b1. What does this mean?
Hi Vonique,
It's true that the Alpha class contains a couple of Beta references--one static and one instance member. However, in the main method of the class Tester, a couple of local Beta instances are created (using the same variable names). So in the code snippet:
a1.b1 (the static Beta variable in the a1 Alpha instance) has assigned to it the value of the local Beta variable b1, and similarly for the other two assignments. So nothing is being assigned to itself in this case. The reason for using the same variable names b1 and b2 is presumably just to make the question a little trickier and to make sure that you're thinking clearly about what's going on.
So after a1, b1, and b2 are set to null, which (if any) of the Beta instances are eligible for garbage collection?