Results 1 to 2 of 2
  1. #1
    riddhik84 is offline Member
    Join Date
    Sep 2009
    Posts
    2
    Rep Power
    0

    Question Java Garbage Collection and destructors

    I am asked several times there two questions in interviews and I need a good answer to give for it if I am asked it in my next interview.

    1. What is Garbage Collection in java? how it works in java?

    2. Why there is no concept of destructors (like in c++) in java?

    Please suggest some good answer to give for these questions at the time of interviews.

    Thanks in advance.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    804
    Rep Power
    6

    Default

    1.Garbage Collection helps programmers from freeing up of allocated memory.It is also very difficult when to free alloted memory.This task has been delicated to JVM by java to make the things more productive.It helps to some extent to avoid memory leaks.

    2.Java is a garbage collected language and it is taken care by itself.So,we can't say when the object will be destroyed.Hence ,there is no destructor in java.

    Please gothru net also to get more info
    Ramya:cool:

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2009, 08:53 AM
  2. How setting an Object to null help Garbage Collection?
    By piyu.sha in forum Advanced Java
    Replies: 3
    Last Post: 10-06-2008, 07:35 AM
  3. Interacting with the Java Garbage Collector
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-28-2008, 08:04 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •