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
Is treeset sorted in java?
What is the epoch date?
Which sorting is used in arrays sort in java?
What is java literals?
Is null a string?
Explain the inheritance?
What is the difference between throw and throws keywords?
What is the equal sign?
What is the use of jtable?
Describe the Big-O Notation.
Can java hashmap have duplicate keys?
What is the flag in java?
How is it possible in java programming for two string objects with identical values not to be equal under the == operator?
What is subsequence of a string?
What are peerless components in java programming?