Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training

Hi, I have trouble to resolve the problem 5. I thought there are 3 objects eligible to gc after line "n3=null". All in all i think that there are 6 Node object created and 3 became eligible for gc. This could be probable due bad understanding of this "Node n3 = new Node(n1.wrap().wrap());".


From this statement I get this: first resolve n1.wrap(), this will create a new Node object( let's call it 'NN') that have his node member linked to n1, then resolve the n1.wrap().wrap(), which can be translated in NN.wrap(), this will create a new Node object(NNN) that have his node member linked to NN and last we resolve Node n3 = new Node(NNN) which create a new Node object and links his node member to NNN object. Could you help me with this?

Me too. Could you explain with more details?

Adrian, what all I can say is your understanding of the flow is perfectly correct, and this is an error in the given answers! In fact, there are three objects eligible for the garbage collector.


Thank you for reporting! And we will correct it tomorrow!


Rivanluiz,


Please feel free to let me know if you still want me to explain any part in this question for you.


ExamLab © 2008 - 2024