• Post Reply Bookmark Topic Watch Topic
  • New Topic

how many objects are eligible for garbage collection?  RSS feed

 
nweoo mon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class C
{
public static void main(String a[])
{
C c1=new C();
C c2=m1(c1);
C c3=new C();
c2=c3; //6
anothermethod();
}
static C m1(C ob1){
ob1 =new C();
return ob1;
}
}
I think 1 objects are eligible for garbage collection, but answers is 2 objects and no explanation.
I want to know explanation, please explain...
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Please QuoteYourSources - where did you find this question?
 
nweoo mon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:Welcome to the Ranch!

Please QuoteYourSources - where did you find this question?


I found this question from this link >>>http://examsguide.com/scjp/freequestions2.html
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question was discussed a few days ago. They seem to agree with you (as do I).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!