Can any one tell me whether at the starting of line 2 how many objects are garbage collcted ?
Thanks in Advance,
posted 9 years ago
Hi, I think the answer is 9 objects are eligible. every time when the loop encounters the new keyword it creats new object and the same q reference variable is pointing to it. At last we are left with 10 objects and only one reference Variable pointing to 10th Object. Thank you