Garbage Collections Questions and Answers
Practice ModeShowing 10 of 32 questions
Q21
Which generation in heap memory contains newly created objects?
Answer: Option B
Explanation: Young generation stores newly created objects.
Q22
What happens if an object survives multiple garbage collection cycles in young generation?
Answer: Option B
Explanation: Objects moving to old generation after surviving young GC.
Q23
Which garbage collector is designed for applications requiring short pause times?
Answer: Option C
Explanation: CMS focuses on reducing pause times.
Q24
What is the permgen space in Java?
Answer: Option C
Explanation: PermGen stored class metadata and was replaced by Metaspace.
Q25
Which reference type always remains in memory until JVM needs memory?
Answer: Option B
Explanation: Soft references are cleared when memory is needed.
Q26
What is a memory leak in context of garbage collection?
Answer: Option C
Explanation: Memory leaks occur when objects are unintentionally retained.
Q27
Which algorithm uses mark and sweep approach?
Answer: Option B
Explanation: Mark and sweep is a basic garbage collection algorithm.
Q28
What is the main advantage of garbage collection?
Answer: Option B
Explanation: Automatic memory management prevents memory leaks.
Q29
Which exception can occur if JVM runs out of memory?
Answer: Option B
Explanation: OutOfMemoryError indicates insufficient memory.
Q30
What is the young generation in Java heap divided into?
Answer: Option B
Explanation: Young generation has Eden and Survivor spaces.