This is an exercise question from K&B and i have a doubt.
To my knowledge, there should be two objects eligible for garbage collection. a1 and b1, but book says only one object is eligible for
garbage collection. Exact explanation is written like this
It should be clear that there is still a reference to the object referred to by a2, and that there is still a reference to the object referred by
a2.b2. What might be less clear is that you can still access the other Beta object through the static variable a2.b1, because its static.
Why a2.b1 is an object? It should be a reference variable having null because we never initialized the value of a2.b1. By default when it is
initialized it will be having a value of null.
I am unable to understand still why only one object is eligible for garbage collection.
What about objects b1 and b2 in main? Please can someone explain me this problem
and this static reference field. I am confused.