This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage colln question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage colln question" Watch "Garbage colln question" New topic

Garbage colln question

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
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;
Eco e;


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?

Thanks<br />Dinesh
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46437
Won't compile. You have copied something wrongly. And you have already been reminded to use the code tags.
Karl Prenton
Ranch Hand

Joined: Mar 10, 2008
Posts: 51
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

Joined: Dec 11, 2004
Posts: 13410


You've also been asked to use real words when posting to JavaRanch.
"bcoz and "colln" are not words in the English language.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
I will take care.
The question is fron KB
I agree. Here's the link:
subject: Garbage colln question
It's not a secret anymore!