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...

What is garbage collection in Java, and how can it be used ?

Answer Posted / surinder mehra

Garbage Collection for an object occurs in following cases:

1) All references of that object explicitly set to null
e.g. object = null
2) Object is created inside a block and reference goes out
scope once control exit that block.
3) Parent object set to null, if an object holds reference
of another object and when you set container object's
reference null, child or contained object automatically
becomes eligible for garbage collection.

Garbage Collectors are implicitly invoked by JVMs when
needed(when there is no enough space for coming objects to
store). or jvm can call garbage collectors whenever it
finds that object is not being used for long time. It is
marked as garbage and later on collected

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain aggregation in java?

971


What is overloading and overriding in java?

1213


What are loops in java?

1244


What is the use of static methods?

1031


Suppose if we have variable ' I ' in run method, if I can create one or more thread each thread will occupy a separate copy or same variable will be shared?

1046


How do you sort in ascending order in java?

863


What is widening and narrowing in java? Discuss with an example.

1033


Give an example of use of pointers in java class.

1021


What is the method to declare member of a class static?

1004


Is java hard to learn?

895


What is a arraylist in java?

1046


What is multiple inheritance? Is it supported by java?

957


What is boolean strategy?

1128


What is ternary operator?

998


extending thread class or implementing runnable interface. Which is better? : Java thread

986