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

How will you get the platform dependent values like line separator, path separator, etc., ?

953


Can you use abstract and final both with a method?

1009


What are loops in java?

1156


What is update method called?

1090


Differentiate between == and equals().

997


What do you mean by stream pipelining in java 8?

1154


What are the types of methodology?

1027


How do you declare a destructor in java?

929


how can i use a nonsynchronized hashtable?

2526


What is the difference between superclass and subclass?

1084


Is it necessary that each try block must be followed by a catch block?

971


Difference between error and exception

5901


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

983


Explain about narrowing conversion in java?

958


Why string objects are immutable in java?

994