| Author |
Garbage Collection in Java
|
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
|
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
Please Quote Your Sources. For example, if you had quoted K&B, we would have mentioned that there is something in the Errata related to this very question. Thanks, Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
Hoe only 2 objects can be eligible along with those two c3 is also becoming null so can't it be null and along with c3 asso.
And BTW, "c3" was never assigned an object. So, how does assigning it to null make something eligible for GC. Remember, objects are elible for GC -- not references. Henry
|
 |
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
Thanks Henry!!! But how Short is eligible. Does it automatically perform "Boxing" Internally!!!???
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
But how Short is eligible.
In the version that you shown, the object is not eligible for GC. In the correct version (version in the Errata for the book), the object is eligible for GC.
Does it automatically perform "Boxing" Internally!!!???
You are assigning a primative value to a wrapper reference. Of course, autoboxing applies -- it's either that, or a compilation error. Henry [ November 30, 2008: Message edited by: Henry Wong ]
|
 |
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
Henry i'm really confuse!!! If there is an errata in the book. The version is got Java 5. Then what should be the correct answer? Thanks.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
|
http://www.coderanch.com/t/257589/java-programmer-SCJP/certification/SCJP-Errata-Updated
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16690
|
|
Then what should be the correct answer?
As you have the question written? One object is eligible for GC. As written in the Errata? Two objects are eligible for GC. Henry
|
 |
Jay Shukla
Ranch Hand
Joined: Jun 08, 2008
Posts: 214
|
|
|
Thanks a lot Henry!!!
|
 |
 |
|
|
subject: Garbage Collection in Java
|
|
|