SCJP 5.0<br /> <br />"Skills are started with learning and mastered with improvement. Nothing is hereditary except death" BUDDHA...
Originally posted by neeraj nandwana:
and the Answer is: Only one CardBoard object (c1) is eligible, but it has an associated Short wrapper object that is also eligible
why "c3" not eligible for GC?
Object "c3" is also have the null value.
Originally posted by neeraj nandwana:
and the Answer is: Only one CardBoard object (c1) is eligible, but it has an associated Short wrapper object that is also eligible
why "c3" not eligible for GC?
Object "c3" is also have the null value.
Originally posted by neeraj nandwana:
hi srinivas
thanks for your help. But i am still confuse.
because c3 hold the null value, and i think It is not mater through which reference it got the value only mater the value, it hold at run time.
SCJP Tiger Hunter 91%.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
C3 = C1.go(C2); // which returns null
Hence, C3 was NEVER assigned to a New Object!
SCJP 93 % ,preparing for SCWCD
Thanks & Regards
Sumit Kothalikar
SCJP 93 % ,preparing for SCWCD
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
Dieter Quickfend wrote:c2 is not null after the go method. c2 the reference variable is copied as a parameter into the go method, and that parameter is set to null, but c2 still points to its assigned object.
OCPJP 6
ahmed yehia wrote:This example is taken from K&B and is corrected in the errata:
In this case 2 Objects are eligible for GC(1 CardBoard(c1), 1 Short).
if Short was less than or equal 127 then c2 would also contain it hence not eligible for GC.
OCJA6, OCJP6
OCPJP 6
Vinoth Kumar Kannan wrote:What about c2 then, isnt assigning null to c2 mean the object it was pointing to previously, eligible for GC?
OCJA6, OCJP6
SCJP 93 % ,preparing for SCWCD
Vinoth Kumar Kannan wrote:
Dieter Quickfend wrote:c2 is not null after the go method. c2 the reference variable is copied as a parameter into the go method, and that parameter is set to null, but c2 still points to its assigned object.
c2 is not copied. By default java passes objects by-reference and not by-value. So, I too feel, c2=null and c1=null => objects referenced by c1 & c2 must be eligible for GC.
Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
OCPJP 6
Don't get me started about those stupid light bulbs. |