This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Which of the following could be a result of attempting to compile and run the program? a. A1A2A3A1 b. A0A0A0A0A1A2A3 c. A1A2A3A1A2A3 d. A1A2A3A1A1A2A3 e. A1A2A3A1A3A2A1 f. A0A1A2A3A1A2A3 My answer was a, c, d, e. The correct answer apparently doesn't include c. A1A2A3A1 is printed in the for loop in method m1. The call to System.gc() does not guarantee the gc will run, so it might be possible none of the object is gc'ed (that's answer a). Another option is they are all gc'ed and that could happen in any order. That gives you answers d and e. Cool. What happens with c? Isn't it possible that A2 and A3 are gc'ed but A1 isn't??? Why not?? It sort of implies the GC might collect everything or not collect anything at all ... Thanks! Edited by Corey McGlone: Added CODE Tags [ March 30, 2004: Message edited by: Corey McGlone ]
Hi Lionel, Answer c is not valid because you'r dealing with so called islands of isolation. The objects refer to each other but there is no live reference to any of them, so they are eligible for garbage collection as a group and no individual object will be missed. Very nice question, may I ask where you got it from? And if it's available for download or something. Greetings, Gian Franco [ March 30, 2004: Message edited by: Gian Franco Casula ]