Java Programming - Garbage Collections - Discussion
Discussion Forum : Garbage Collections - Pointing out the correct statements (Q.No. 1)
1.
Which statement is true?
Answer: Option
Explanation:
Option D is correct.
Option C is wrong. See the note above on Islands of Isolation (An object is eligible for garbage collection when no live thread can access it - even though there might be references to it).
Option B is wrong. "Never again be used" does not mean that there are no more references to the object.
Option A is wrong. Even though Java applications can run out of memory there another answer supplied that is more right.
Discussion:
1 comments Page 1 of 1.
Alexander Monakhov said:
2 decades ago
"Objects that can be reached from a live thread will never be garbage collected."
Very misleading. If the thread nullifies reference to some object, the object becomes eligible for GC. Thus, the statement "will never" is formally wrong.
In contrast, B is right with some addition.
"Objects that are guaranteed not to be used again are eligible for garbage collection."
Very misleading. If the thread nullifies reference to some object, the object becomes eligible for GC. Thus, the statement "will never" is formally wrong.
In contrast, B is right with some addition.
"Objects that are guaranteed not to be used again are eligible for garbage collection."
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers