Hi
I found this question in whizlab
test class TestGC{
TestGC aRef;
public static void main(
String args[])
{
TestGC a = new TestGC();
TestGC b = new TestGC();
TestGC c = new TestGC();
a.aRef = b; //->line 1
b.aRef = c; //->line 2
c.aRef = a; //->line 3
c = new TestGC();
a=b=c; //->line 4
system.gc();
}}
So After line 4 , how many objects will eligible for garbage collection?
Ans:-3, but i got confused due to line 1,2,3. aRef is still reffreing to all three objects.
Please explain what is happening at line1,2,3?
Thanks