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 is bytecode in java ?
Why vector is used in java?
How do you bind variables?
What is a function argument in java?
What is the primary benefit of encapsulation?
What is an empty string in css?
Java openings 3 - 5 years, Lnt Infotech. requirements - core java, J2ee, struts, hibernate Interview Date:- 19 March 2011 Time:- 9:00 AM to 12:00 Pm Interview Location - L & T Infotech, Manapakkam, Chennai Refererral PS NO:- 291649 (Please mention this when u fill the form only then u will be considered for interview) Documents Required:- Latest Resume, Photograph and last 3 payslips Mail me on vasan2211@gmail.com once u appear for interview
What does %d do in java?
What do you understand by copy constructor in java?
How many functional interfaces does java 8 have?
what is the purpose of the runtime class?
What are the restrictions that are applied to the java static methods?
What is stream api in java8?
How can we make a class virtual?
What is the purpose of java?