| Author |
Garbage collection doubt
|
Mahmoud Metwaly
Greenhorn
Joined: Jul 16, 2008
Posts: 14
|
|
Assuming we have the following method Now by exiting this method, how many objects are eligible for garbage collection 4 OR 5 (if we are going to count 4 objects of the array + the array object itself)? Thanks in advance
|
Mahmoud Metwally<br />Preparing for SCJP...<br /> <br />"Try not to become a man of success but a man of value" - Albert Einstein
|
 |
Bob Ruth
Ranch Hand
Joined: Jun 04, 2007
Posts: 318
|
|
I'm going to take a guess and say one. Here's why I say that: the statement instantiates an array large enough to hold four String references..... and then nulls them all. They do not contain instances of strings yet. So I think that the only object there is the array. [ July 29, 2008: Message edited by: Bob Ruth ]
|
------------------------
Bob
SCJP - 86% - June 11, 2009
|
 |
Lino Larios
Greenhorn
Joined: Jun 27, 2008
Posts: 28
|
|
I think that one only object the array , because the array is just holding 4 references variables [ July 29, 2008: Message edited by: Lino Larios ]
|
 |
Ronald Schild
Ranch Hand
Joined: Jun 09, 2008
Posts: 117
|
|
|
Only the array object. All the references in the array are set to null as default value, and no String objects are created.
|
Java hobbyist.
|
 |
Vinod Kumar Kommineni
Ranch Hand
Joined: Jun 12, 2008
Posts: 54
|
|
|
ya its only one object ... since they are not intialised to refer any object
|
Regards
vinod SCJP 6.0
|
 |
 |
|
|
subject: Garbage collection doubt
|
|
|