ishani sharma wrote:At (1) 3 objects are eligible for garbage collection.
No. You are still in the main method, so no objects are eligible for GC
ishani sharma wrote:At (2) 4 objects are eligible for garbage collection
As you only create 3 objects, that's highly unlikely.
ishani sharma wrote:At (3) 3 objects are eligible which are i2, i3, i4 and the objects i2.i, i3.i, i4.i are not eligible
Again, you are only creating 3 objects.
i2, i3, i4, i2.i, i3.i and i4 are object references. These are never garbage collected - only objects are garbage collected. Object references refer to objects and you can have several references referring to a single object. You need to work out which references refer to which objects and then once you've done this, if there is an object with no references, it will be eligible for GC.