wood burning stoves*
The moose likes IDEs, Version Control and other tools and the fly likes Questions on GC from Khalid A.Mughal, Chap 9 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Reply locked New topic
Author

Questions on GC from Khalid A.Mughal, Chap 9

Anuradha Prasanna
Ranch Hand

Joined: Mar 09, 2006
Posts: 115
On page 402 & 403 of this book, there are no answers for four GC questions.

1)How many objects are eligible for GC when control reaches (1)?


I think, 9 objects are eligible for GC. is that right?
but the answers are,
(A)0
(B)5
(c)10

can anyone tell the right answer with explanation?
--------------------------------------------------------------------------------------------------------------------------------------
2)How many objects are eligible for GC when control reaches (1)?

I think, 0 objects are eligible for GC. is that correct?

--------------------------------------------------------------------------------------------------------------------------------------

3)How many objects are eligible for GC when control reaches (1)?


I think, 0 objects are eligible for GC here. Is that right?
--------------------------------------------------------------------------------------------------------------------------------------

4) How many objects are reachable when control reaches (1)?


I think 5 objects are reachable.(Integer[] obj with reference array & 4 objects pointed to by the references array[0], array[1], array[2], array[3])
is it correct?


SCJP 6.0 90%
Burk Hufnagel
Ranch Hand

Joined: Oct 01, 2001
Posts: 814
    
    3
Anuradha,

You're posting in the wrong forum. This looks like a question for the SCJP forum.

BTW, I didn't look at the rest but your answer for #1 is wrong. Take a look at the code, a new instance of Eligible gets created each time through the loop but no reference is kept. So the correct answer is the number of times the loop executes - which isn't nine.

Good luck with your studies. I recommend Kathy Sierra and Bert Bate's SCJP Study Guide - but I'm partial as I was one of the technical reviewers. Still I've used it as the textbook for an SCJP study group and everybody seemed to like the book and the folks who took the exam passed so I guess there's objective proof that it's a good book. Of course it doesn't hurt that KAthy and Bert helped write the exam...

Burk

SCJP, SCJD, SCEA 5 "Any sufficiently analyzed magic is indistinguishable from science!" Agatha Heterodyne (Girl Genius)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place. Please read this for more information.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Questions on GC from Khalid A.Mughal, Chap 9