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
say me when this eill actually happen.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are different types of arrays?
What restrictions are placed on method overriding in java programming?
What is the use of flag?
Is minecraft java edition free?
How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?
What will happen to the exception object after exception handling?
Explain about object oriented programming and its features?
Difference between ‘is-a’ and ‘has-a’ relationship in java?
What is formatted output?
What is Garbage Collection in Java
How can a gui component handle its own events in java programming?
What is a file pointer?
What are Normalization Rules? Define Normalization?
What are the advantages of encapsulation in java?
Give few difference between constructor and method?