• Post Reply Bookmark Topic Watch Topic
  • New Topic

Objects eligible for garbage collection  RSS feed

 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Explain me how many OBJECTS are eligible for GARBAGE COLLECTION in following code when //dostuff is reached


This question is given the book SCJP Programmer Study Guide written by Kathy Seirra And Bert Bates.

Answer is given only 2 Objects

no.1 is Object c1 and another one is shortcut wrapper Object associated with Object c1

What is Shortcut Wrapper Object??

i am not geeting this one.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vishal mishra wrote:Please Explain me how many OBJECTS are eligible for GARBAGE COLLECTION ... ANSWER IS 2 .PLEASE EXPLAIN ME HOW??

Please EaseUp (←click).

Winston
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you post a question, please tell where you found it.

Did you think the answer should be more, or less than, two? Remember that when an object becomes unreachable, it becomes eligible for garbage collection. Does that help?
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well SORRY if i wrote anything wrong .

I didn't mean that my query is "Urgent".

I just tried to make my point clear.
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is given the book SCJP Programmer Study Guide written by Kathy Seirra And Bert Bates.

Answer is given only 2 Objects

no.1 is Object c1 and another one is shortcut wrapper Object associated with Object c1

What is Shortcut Wrapper Object??

i am not getting this one.
 
Gaurangkumar Khalasi
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vishal mishra wrote:
What is Shortcut Wrapper Object??


It is not shortcut???

It is a Short wrapper object...Declared in the program... Short story = 200;

The Short class wraps a value of primitive type short in an object. An object of type Short contains a single field whose type is short.


For more Info.:
docs.oracle.com/javase/7/docs/api/java/lang/Short.html
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every instance of CardBoard has an instance field named story that is a reference to a Short object. When that CardBoard instance becomes unreachable (for example, because the reference to it has been set to null) -- then what happens to the Short object that story refers to? Can it still be reached?
 
vishal mishra
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am such a BIG FOOL !!

Thanks !!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!