From
http://examsguide.com/scjp/freequestions2.html: For the below code, how many objects are eligible for collection after line 6 ?
Answer says 2.
But I can only see 1 object is eligible.
After line 3, c1 points to object1.
After line 4, object1 becomes eligible; both c1,c2 point to new object2.
After line 5, c3 points to object3.
After line 6, c2, c3 point to object3; c1 still points to object2.
after line 6, how many objects are eligible for garbage collection?
Ans: 1
Ans: 2
Ans: 3
Ans: 4
None of the above
Explanation:
No Explanation Available
Also another one from the same page: these may just be badly formated, but the below code seems to create only 2 objects.
14)
1. StringBuffer s1 = new StringBuffer("abc");
2. StringBuffer s2 = s1;
3. StringBuffer s3 = new StringBuffer("abc");
How many objects are created ?
0
Ans: 1
Ans: 2
Ans: 3
Explanation:
No Explanation Available
Ans: 4
[ November 26, 2008: Message edited by: Clay Chow ]