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
How do you create a reference in java?
What is boolean keyword in java?
What is binary search in java?
What are the advantages of exception handling?
What is the inheritance?
What is meant by bytecode?
What is the difference between serializable and externalizable interface?
What is parsing in grammar?
What is the maximum size of arraylist in java?
What is the importance of hashcode() and equals() methods?
What is set string?
Why bytecode is called bytecode?
What is the use of parse function in java?
What is difference between == and === in js?
What does mean in regex?