Skip to content
Sharp

Garbage Collection · interview question

How would you explain a key reason for Stop-The-World pauses during garbage collection in an interview?

Multiple choiceHardchapter-14-curatedpremiumgarbage-collectiongenerational-gc
Choose one answer
Answer and explanation

Correct answer

C. To safely traverse and modify object references without interference from running threads.

Why

Stop-The-World pauses are necessary for safely traversing and modifying object references during garbage collection. This ensures that no threads are modifying the heap while the GC is working, preventing inconsistencies.

Test yourself on Garbage Collection

A free test with instant, explained results. No account needed.

Start free test
All Garbage Collection questions →