This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method returns what happens to garbage collection

 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following code is from OCP Practice Exam book. It says





D. Four objects are eligible for garbage collection.



How the answer is changed in folowing case




 
dennis deems
Ranch Hand
Posts: 808
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not all of us carry our K&B books around all day. ;) So give us the full question please. Then, tell us what YOU think will happen if the code is changed as you suggest.
 
Jeffrey Tian
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I has doubt on this question:

On Line 15. a3.password = a1.acctNum.longValue();
an object is created. The total number of objects should be 5. Am I right?
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is Complete question :



When line 8 is reached, which are true? (Choose all that apply.)
A. a1.acctNum == a3.password
B. a1.password == a2.password
C. Three objects are eligible for garbage collection.
D. Four objects are eligible for garbage collection.
E. Six objects are eligible for garbage collection.
F. Less than three objects are eligible for garbage collection.
G. More than six objects are eligible for garbage collection.

Correct Ans : D


Now follow :
As if change is made in Banker class


As with my understanding None of the object is eligible for GC since ob still hold the reference to the object(s).
 
Jeffrey Tian
Ranch Hand
Posts: 34
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like all of us didn't Google this questions. This question has been discussed a lot in this forum. Click Here

I have another concern on answer B. The book says: B is correct, although when line 8 is reached, the references are lost.
Both references have gone, how can we compare them?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic