| Author |
Possible error OCJP Practice Exams, exam 3 question 28
|
John Wintermute
Greenhorn
Joined: Nov 01, 2011
Posts: 13
|
|
Hi all,
When I worked through this question, I ended up with five objects, but the answer says it's only four. It seems to me that one Banker, one Account and three Longs are created
I ran the code through the debugger in Eclipse and, indeed, Long instances are created with different IDs at lines 1,2 and 3.
Would anyone care to comment on that?
Many thanks!
-john
|
ocjp december 2011 -
may peace prevail on earth
|
 |
Thomas Kennedy
Ranch Hand
Joined: Jan 20, 2008
Posts: 137
|
|
You didn't post the exact question. If it asked you how many objects are created by the whole program that's one thing, but if it asked how many are created between certain lines that's another.
I'm going to examine how many are created just within the go() method.
I think the supplied answer, four objects, is correct if they meant just the doings within the go() method.
|
Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
|
 |
John Wintermute
Greenhorn
Joined: Nov 01, 2011
Posts: 13
|
|
Hi Thomas,
Yes, you are indeed correct - it's how many are eligible when the method ends. Another case of "read the question properly"
thanks!
john
|
 |
Jagat Sastry
Greenhorn
Joined: Feb 25, 2012
Posts: 3
|
|
John, I think you're right. The question asks "When line 8 is reached, which are true?"
When line 8 is reached, you have those 4 objects mentioned by Thomas, plus the Banker object created in line 7 that would be eligible for GC.
That makes it five objects eligible for GC, right?
|
 |
An Tran
Greenhorn
Joined: Jan 25, 2012
Posts: 2
|
|
|
Yes, it's 5 and was confirmed by the author here http://www.coderanch.com/t/531928/java-programmer-SCJP/certification/Garbage-Collection-found-OCP-Java
|
 |
 |
|
|
subject: Possible error OCJP Practice Exams, exam 3 question 28
|
|
|