Bird
0
0

What is the main purpose of garbage collection in Java?

easy📝 Conceptual Q11 of 15
Java - Memory Management Basics
What is the main purpose of garbage collection in Java?
AIncrease the size of the heap memory
BAutomatically free memory used by objects no longer needed
CManually delete objects from memory
DCompile Java code into bytecode
Step-by-Step Solution
Solution:
  1. Step 1: Recall the purpose of garbage collection and evaluate options

    Garbage collection automatically frees memory used by objects that are no longer referenced in the program. Only "Automatically free memory used by objects no longer needed" matches this definition.
  2. Final Answer:

    Automatically free memory used by objects no longer needed -> Option B
  3. Quick Check:

    Garbage collection = automatic memory freeing [OK]
Quick Trick: Garbage collection frees unused memory automatically [OK]
Common Mistakes:
  • Thinking garbage collection deletes objects manually
  • Confusing garbage collection with compiling code
  • Believing it increases heap size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes