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
Why is java logo a cup of coffee?
Is oracle java 11 free?
What is the purpose of the strictfp keyword?
What Is Query Throttling in java?
What is the method to declare member of a class static?
What are the different tags provided in jstl?
What is a super method?
Name few "optional" classes introduced with java 8 ?
Explain what do you mean by functional overloading in java?
What are the different collection views provided by maps?
How is the marker interface used in Java?
Which is the best sorting technique in java?
Which class is used by server applications to obtain a port and listen for client requests?
What is assembly used for?
What language is java written?