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 / namita

First We cannot force the garbage collection to garbage the
object. Garbage collection can never be forced.

So by calling System.gc() will not ensure you that the
object will be garbage collected.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When can you say a graph to be a tree?

1027


What is a return in java?

976


What is a method header?

969


What is meant by vector class, dictionary class, hash table class, and property class?

1082


What is time complexity algorithm?

988


Why heap memory is called heap?

991


What are the differences between checked exception and unchecked exception?

921


what do you mean by stream pipelining in java 8? Explain

972


What is treeset in java collection?

918


What is the difference between heap and stack memory?

1135


what is the difference between a threads start() and run() methods? : Java thread

961


Is null a value?

970


How hashset works internally in java?

1013


worst case complexities of Quick sort and Merge sort.

948


What is try-with-resources in java?

1101