Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection in Java

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Henry Wong
author
Marshal
Pie
Posts: 21409
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Henry Wong
author
Marshal
Pie
Posts: 21409
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry!!!

But how Short is eligible.
Does it automatically perform "Boxing" Internally!!!???
 
Henry Wong
author
Marshal
Pie
Posts: 21409
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21409
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Henry!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic