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
How can we find the actual size of an object on the heap?
Why is logger singleton?
Can we have a method name same as class name in java?
How infinite loop is declared?
What are the differences between string and stringbuffer?
What is var keyword ?
What is the difference between delete and delete[]
What is composition in java?
please send me hr interview questions in it industry
What is class??
Why volatile is used in java?
What are the steps that are followed when two computers connect through tcp?
What happens if we override only equals?
What is unicode datatype?
What is a default constructor and also define copy contrucyor?