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


Please Help Members By Posting Answers For Below Questions

Why is java logo a cup of coffee?

620


Is oracle java 11 free?

524


What is the purpose of the strictfp keyword?

609


What Is Query Throttling in java?

561


What is the method to declare member of a class static?

534






What are the different tags provided in jstl?

548


What is a super method?

530


Name few "optional" classes introduced with java 8 ?

641


Explain what do you mean by functional overloading in java?

553


What are the different collection views provided by maps?

563


How is the marker interface used in Java?

606


Which is the best sorting technique in java?

518


Which class is used by server applications to obtain a port and listen for client requests?

491


What is assembly used for?

502


What language is java written?

535