Dear programmers
While navigating in the internet I have seen the following Question:
class C{
public static void main(String a[]){
C c1=new C();
C c2=m1(c1);
C c3=new C();
c2=c3; //6
anothermethod();
}
static C m1(C ob1){
ob1 =new C();
return ob1;
}
}
After line 6, how many objects are eligible for garbage collection?
Answer: 2
Maybe someone can tell me why the answer is 2?
I seems to me that the answer should be 1
(only c2 is eligible)