| Author |
Objects eligible for garbage collection
|
vishal mishra
Ranch Hand
Joined: Jul 12, 2010
Posts: 79
|
|
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
Joined: Mar 17, 2011
Posts: 4761
|
|
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
|
Isn't it funny how there's always time and money enough to do it WRONG?
|
 |
dennis deems
Ranch Hand
Joined: Mar 12, 2011
Posts: 808
|
|
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
Joined: Jul 12, 2010
Posts: 79
|
|
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
Joined: Jul 12, 2010
Posts: 79
|
|
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
Joined: Jun 02, 2012
Posts: 186
|
|
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
Joined: Mar 12, 2011
Posts: 808
|
|
|
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
Joined: Jul 12, 2010
Posts: 79
|
|
I am such a BIG FOOL !!
Thanks !!
|
 |
 |
|
|
subject: Objects eligible for garbage collection
|
|
|