Java Programming - Garbage Collections - Discussion
Discussion Forum : Garbage Collections - Pointing out the correct statements (Q.No. 3)
3.
Which statement is true?
Answer: Option
Explanation:
Option B is correct. If an object can be accessed from a live thread, it can't be garbage collected.
Option A is wrong. Runtime.gc() asks the garbage collector to run, but the garbage collector never makes any guarantees about when it will run or what unreachable objects it will free from memory.
Option C is wrong. The garbage collector runs immediately the system is out of memory before an OutOfMemoryException is thrown by the JVM.
Option D is wrong. If this were the case then the garbage collector would actively hang onto objects until a program finishes - this goes against the purpose of the garbage collector.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers