Page 1 of 1
About Question com.enthuware.ets.scjp.v6.2.561 :
Posted: Mon Aug 29, 2011 8:23 pm
by ETS User
public void process(int count) //line 1
{
for ( int i = 1; i < count; i++ ) //line 2
{
Object temp = new Object(); // line 3
}
// Line 4
}
My thinking was 5 objects are available for gc after line 4. 4 from temp and 1 from variable i.
your answer does to consider the scope for i, please clarify
Re: About Question com.enthuware.ets.scjp.v6.2.561 :
Posted: Sat Sep 03, 2011 12:16 am
by admin
variable i is a primitive type. They are not even objects. Primitives are never GCed.
Re: About Question com.enthuware.ets.scjp.v6.2.561 :
Posted: Fri Oct 14, 2011 3:16 pm
by Guest
ETS User wrote:public void process(int count) //line 1
{
for ( int i = 1; i < count; i++ ) //line 2
{
Object temp = new Object(); // line 3
}
// Line 4
}
My thinking was 5 objects are available for gc after line 4. 4 from temp and 1 from variable i.
your answer does to consider the scope for i, please clarify
I was thinking the same thing. Thanks for the clarification!
Re: About Question com.enthuware.ets.scjp.v6.2.561 :
Posted: Mon Nov 05, 2012 9:28 pm
by ETS User
I think correct answer here is 0, because all the references are active and not nulled. Particularly if keep in mind that even if all references and references are nulled, its not a guarantee that gc will run...