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
About Question com.enthuware.ets.scjp.v6.2.561 :
Moderator: admin
-
- Site Admin
- Posts: 10398
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.561 :
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 :
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 :
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...
Who is online
Users browsing this forum: No registered users and 9 guests