At line 20 how many objects are available for Garbage collection?
My Ans is 2 objects will be Garbage Collected.But some say it to be 4.
My Solution:
s1--->SO1. At line 13.Lets acronym Sparrow Object as SO;
s2--->SO2. At line 14.
s3--->SO3. At line 15.
After line 16:s1--->SO3 ,s2--->SO2,s3--->SO3.So SO1 available for GC.
After line 17:s1--->SO3 ,s2--->SO3,s3--->SO3.So SO2 available for GC.
After line 18:s1--->SO3 ,s2--->null,s3--->SO3.
After line 19:As both s1 and s3 refer to same object, nothing much wrt GC is going to happen in this line.
Is this correct? some say 4 objects will be Garbage collected.