Q.58.At what point is the object obj eligible for garbage collection?(sun's mock2)
(Select one correct answer)
public class Test058 {
public
String m() {
Object obj = new String("");
String str = null; //1
str = (String)obj; //2
obj = null; //3
return str;
}
}
A: After line //1.
B: After line //2.
C: After line //3.
D: Never
Ans

-The object is returned by the method and not eligible for garbage collection during
the lifetime of the method.
--> i think even after returning from the method, the object earlier referenced by obj may or not may not(if it is assigned to some ref. variable in the caller method) eligible for garbage collection. Am i right here??
ashok.