Bird
0
0

Why does Java use garbage collection instead of manual memory management for object lifetime?

hard📝 Conceptual Q10 of 15
Java - Memory Management Basics
Why does Java use garbage collection instead of manual memory management for object lifetime?
ABecause Java objects never get deleted
BTo prevent memory leaks and dangling pointers automatically
CTo make programs run faster by deleting objects immediately
DBecause Java does not allow creating objects manually
Step-by-Step Solution
Solution:
  1. Step 1: Understand manual memory management problems

    Manual memory management can cause errors like memory leaks and dangling pointers.
  2. Step 2: Know Java's design choice

    Java uses garbage collection to automatically manage memory safely and reduce programmer errors.
  3. Final Answer:

    To prevent memory leaks and dangling pointers automatically -> Option B
  4. Quick Check:

    Garbage collection prevents memory errors = true [OK]
Quick Trick: Garbage collection avoids manual memory errors [OK]
Common Mistakes:
  • Thinking Java objects can't be created manually
  • Believing garbage collection makes programs faster always
  • Assuming objects never get deleted

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes