AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“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!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: sandynaik — October 6, 2006
    +10 votes
      + -

    No
    garbage collector does the job working in the background

  2. Submitted By: jaysesh — October 6, 2006
    +6 votes
      + -

    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

  3. Submitted By: mnigam — October 6, 2006
    +3 votes
      + -

    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.

  4. Submitted By: Ryan J. McDonough — October 10, 2006
    -3 votes
      + -

    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 ;)

  5. Submitted By: shradha — December 25, 2006
    +2 votes
      + -

    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.

  6. Submitted By: yes — April 19, 2007
    -5 votes
      + -

    yes
    java has destructor thats name is garbage collector.

  7. Submitted By: CSGodFather — January 13, 2008
    +1 votes
      + -

    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

  8. Submitted By: Shemi — September 30, 2008
    not yet rated
      + -

    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!

  9. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.