Gabbage Collection
807605Aug 16 2007 — edited Aug 17 2007Answer? Well, I think r2 is always referred to, likewise r3, r4 and r5. r1 seems inaccessible, but is still reffered to on line 10. So is the answer none or can r1 still be gabbage collected pls?
Thanx
Given:
1. class Rubbish {
2. public static void main(String [] args) {
3. Rubbish r1 = new Rubbish();
4. Rubbish r2 = new Rubbish();
5. Rubbish r3 = new Rubbish();
6. Rubbish r4 = r2;
7. Rubbish r5 = r4;
8. r2 = null;
9. r4 = r2;
10. r1 = r5;
11. // do stuff
12. }
13. }
At the point that line 12 is reached, how many objects are eligible for garbage collection?