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

What is return code?

1059


Explain about join() method?

1027


What does provide mean construction?

1156


When is the finally clause of a try-catch-finally statement executed?

1138


What is the difference between interface & abstract class?

1086


Define how does a try statement determine which catch clause should be used to handle an exception?

1252


Name the components that are termed to be Heavy-weight component but available in Light-weight components?

2533


How do you implement polymorphism in our day to day life?

3284


Implement 2 stacks with just 1 array. The stack routines must not indicate overflow unless every slot in array is used.

1371


What is the relationship between class and object?

1093


What is a java object and java application?

1088


What is variable explain with example?

1113


Explain exception chaining in java?

1223


Can we override constructor?

1083


What are the 8 data types in java?

1043