Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

public class Garbage
{
int a=0;
public void add()
{
int c=10+20;
System.out.println(c);
System.out.println(a);
}
public static void main(String args[])
{
Garbage obj=new Garbage();
System.gc();
System.out.println("Garbage Collected");
obj.add();
}
}
Above is a code in java used for garbage collection. object
obj has been created for the class Garbage and system.gc
method is called. Then using that object add method is
called.System.gc method if called the obj should be garbage
collected?

Answer Posted / madhu

Garbage Collector is called by the JVM. and it will collect
the objects which has no reference, in the above case obj
has reachability,so JVM won't force the garbage collector to
collect the obj object.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is hotjava?

950


What is the difference between overriding & overloading?

1003


What is the requirement of thread in java?

994


What data type is string java?

909


What are the legal parameters?

942


what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread

928


What is purpose of applet programming?

1134


Is hashset ordered java?

1035


What is a parameter in java?

951


Difference between Linked list and Queue?

978


What kind of variables can a class consist?

997


What are the advantages and disadvantages of object cloning?

1040


How do I enable java in safari?

980


What is javac_g?

968


What is a Null object?

1525