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
What function extracts specified characters from a string?
What is the difference between static (class) method and instance method?
What is overloading and overriding in java?
What flag up means?
What mechanism does java use for memory management?
Is array size fixed in java?
What is the size of an array?
Why does my function print none?
What is native code?
What is jee6?
Is linked list a linear or non-linear data structure?
What about method local inner classes or local inner classes in java?
Explain about the security aspect of java?
How many bytes are there?
What is floor math?