Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage colln question

 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Eco
{
public statci void main(String []s)
{
Eco e1= new Eco();
Eco e2= new Eco();
Eco e3= new Eco();
e3.e = e2;
e1.e = e3;
e2.e1=e1;
e1=null;
e2=null;
e3=null;
}
Eco e;
}

Ranchers,

How many objects are eligible for gc?
According to me all three objects,bcoz all have been assigned null.

Correct me if ia m wrong?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49765
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't compile. You have copied something wrongly. And you have already been reminded to use the code tags.
 
Karl Prenton
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to be frank
the fact that the references have been nulled is irrelevant the program terminates so they all get GC!
you need to ask the right question...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dinesh,

You've also been asked to use real words when posting to JavaRanch.
"bcoz and "colln" are not words in the English language.
 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will take care.
The question is fron KB
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic