void method X() {
String r = new String("abc");
String s = new String("abc");
r = r+1; //1
r = null; //2
s = s + r; //3
} //4
when is s eligible for garbage collection?
Before statement labeled 1
Before statement labeled 2
Before statement labeled 3
Before statement labeled 4
Never
i answered never, but the correct answer is 'before statement labeled 4'.
I didnt understand yy?
is is bcos s = s + r and r = null. anything added to null is null?