Hi All,
Can anybody please help me understanding the output of this program... It's a question from Devaka's
ExamLab.... And i'm unable to understand how to get the answer... can anybody please explain it to me...
How many objects are eligible for GC after executing line-10.
1.public class Garb{
2. Garb g;
3. pulic Garb(Object g){
4. this.g = (Garb) g;
5. }
6. public static void main (
String args[]){
7. Garb gb1 = new Garb(new Garb(new Garb(null)));
8. gb1.g.g = new Garb(new Garb(null));
9. Garb gb2 = new Garb(new Garb(new Garb(gb1)));
10. gb2.g = gb1.g;
11. System.gc();
12. }
13. }