How does the garbage collector know if an object can be collected?
Interview Answers
Anonymous
Apr 24, 2014
1.when the object is no longer referenced by anyother object.
2. when the obj is defined null
1
Anonymous
Jan 5, 2016
Reference counting is a form of garbage collection whereby each object has a count of the number of references to it. Garbage is identified by having a reference count of zero. An object's reference count is incremented when a reference to it is created, and decremented when a reference is destroyed. When the count reaches zero, the object's memory is reclaimed. (Wikipedia)