class I {
private I other;
public void other(I i) {other = i;}
}
class J {
private void m1() {
I i1 = new I(), i2 = new I();
I i3 = new I(), i4 = new I();
i1.other(i3); i2.other(i1);
i3.other(i2); i4.other(i4);
}
public static void main (
String[] args) {
new J().m1();
}}
Which object is not eligible for garbage collection after method m1 returns?
a. i1
b. i2
c. i3
d. i4
e. Compile-time error
f. Run-time error
g. None of the above
I think the object referenced by i4 is not eligible for collection cos it does not form an island of object.The instance variable refers to its own reference varible.But the answer says all are eligble for garbage collection. Is it becos i4 ia a local reference and is cleared off the stack when the method is exited?
Pls clarify