When Is An Object Subject To Garbage Collection


  • 7 Aug, 2012

    an object is subjected to garbage collection if it is left unused for a long time.

    for example,

    Student s1= new Student();

    Student s2= new Student();

    s1.name="abc";

    s1.add();

    s1.remove();

    like this if we keep on using s1 and left s2 then after some amount of time it is subjected to garbage collection.

    Comments Received:
    Please give your suggestions and feedback:
  • 12 May, 2012

    if an object is not reachable then that object is eligible for garbage collection. Here reachable means we dont have anyway to access that object. that means no reference variable holds that object, simply object is present in heap memory but no reference variable points to that object. in this case object is eligible for garbage collection. 

    Comments Received:
    Please give your suggestions and feedback:
  • 29 Dec, 2011

    An object is subject to garbage collection when it becomes unreachable to the program in which it is used.

    Comments Received:
    Please give your suggestions and feedback:

2009-2016 downloadmela.com. All rights reserved.