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 / maverickhari
Thanks Namita
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Does printwriter create a file?
What is the preferred size of a component in java programming?
Is boolean a wrapper class in java?
what is difference between equals and ==?
What is object-oriented paradigm?
What is a conditional equation?
Can an interface implement another interface?
What are the different ways of creating thread?
Difference between keyword and identifier.
What is an class?
List the interfaces which extends collection interface?
Can You Have Virtual Functions In Java?
Is the milky way in a void?
What one should take care of, while serializing the object?
What is meant by 'bit masking' in java?