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
When is update method called?
how we can make a write-only class in java?
What are use cases?
enlist some features of jdk.
What is runtime locatable code?
What is static data type in java?
In java, how many ways you can take input from the console?
What is supplier in java?
What is the size of arraylist in java?
What is use of super keyword in java?
Why is it called boolean?
Why do people says “java is robust”?
What is the difference between class forname and new?
What is an object in java?
How does arraylist size increase in java?