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

Write a factorial program using recursion in java?

1014


In how many ways we can do synchronization in java?

961


What is the purpose of default constructor?

998


What is a functional interface?

1015


What is <> used for in java?

1110


How many bits are in a sentence?

1164


Which method cannot be overridden in java?

988


Can bool be null?

983


Can you instantiate the math class?

1057


How is abstraction implemented in java ?

998


What is difference between array and arraylist in java?

988


Implement a stack with push (), pop() and min() in O(1) time.

1107


What is the multi-catch block in java?

1032


What is an anonymous class in java?

1095


What is the difference between JDBC 1.0 and JDBC 2.0?

3177