i have a doubt in this question..please explain..
Given the following code, how many objects will be eligible for garbage collection on the line with the comment //here
public class BettyAck {
public static void main(
String argv[]){
BettyAck b =new BettyAck();
}
public BettyAck() {
Integer x = new Integer(10);
findOut(x);
Integer y = new Integer(99);
Integer z = y;
z = null;
findOut(y);
//here
}
public void findOut(Integer y){
y = null;
}
a)0
b)1
c)2
d)3
e)4
i think the answer is 2.
1.y=null means (the reference y and x points nothing or the value of the object 10 becomes null)i think the first one is correct
2.can i say only two objects are created in the above code...(the space allocated only for "10" and "99") (x,y,z are references)