“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
Java does not have destructors. Garbage collector does this job periodically depending upon the memory requirements of the machine and on the fact that a particular object is no longer needed.
Using finalize() does not guarantee that it would be called b4 garbage collector is invoked.
Submitted By: Ryan J. McDonough — October 10, 2006
This is a dicey question. While core Java does not have destrcutors, may classes in the Eclipse SWT API do in fact have destructors. You must explicitly call component.dispose() when you are done with a visual component. So, Java can have destructors depending on what API you’re using
No.
There are no destructores in Java.
If any variable just declered in your code not used
anywhere in the code then Garbage collector will
automatically deallocates the space allocated for
that variable.
It is one among the fetures of Java language.
You guys still dont know garbage collection in java very well. I agree on the part where there are no destructors. However, Finalize is just called (at most) once by garbage collector, and there is no documentation saying that garbage collector will ever RUN. In fact, NOTHING IN GARBAGE COLLECTOR IS GUARANTEED. Also, remember that you could save object state in finalize and hence when finalize run before gc, the object which was supposed to be garbage collected would have been saved. FINALIZE CAN PREVENT OBJECT GC
Sincerely,
GodFather
java doea not have destructors…
this job is done by the garbage collecter. It automatically removes objects which do not have any references and hence cannot be accessed…
calling the finalize() method is a request for garbage collection.. u cannot force any object to be garbage collected.. finalize() can be used to store any information before an objected is removed from memory!
No
garbage collector does the job working in the background
Jva does not have destructors; but it has finalizers that does a similar job.
the syntax is
public void finalize(){
}
if an object has a finalizer, the method is invoked before the system garbage collects the object
Java does not have destructors. Garbage collector does this job periodically depending upon the memory requirements of the machine and on the fact that a particular object is no longer needed.
Using finalize() does not guarantee that it would be called b4 garbage collector is invoked.
This is a dicey question. While core Java does not have destrcutors, may classes in the Eclipse SWT API do in fact have destructors. You must explicitly call component.dispose() when you are done with a visual component. So, Java can have destructors depending on what API you’re using
No.
There are no destructores in Java.
If any variable just declered in your code not used
anywhere in the code then Garbage collector will
automatically deallocates the space allocated for
that variable.
It is one among the fetures of Java language.
yes
java has destructor thats name is garbage collector.
You guys still dont know garbage collection in java very well. I agree on the part where there are no destructors. However, Finalize is just called (at most) once by garbage collector, and there is no documentation saying that garbage collector will ever RUN. In fact, NOTHING IN GARBAGE COLLECTOR IS GUARANTEED. Also, remember that you could save object state in finalize and hence when finalize run before gc, the object which was supposed to be garbage collected would have been saved. FINALIZE CAN PREVENT OBJECT GC
Sincerely,
GodFather
java doea not have destructors…
this job is done by the garbage collecter. It automatically removes objects which do not have any references and hence cannot be accessed…
calling the finalize() method is a request for garbage collection.. u cannot force any object to be garbage collected.. finalize() can be used to store any information before an objected is removed from memory!
Leave an Answer/Comment