File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage colln question" Watch "Garbage colln question" New topic
Author

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;
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?


Thanks<br />Dinesh
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38793
    
  23
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
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Dinesh,

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: http://aspose.com/file-tools
 
subject: Garbage colln question