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:
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.
Final Answer:
Automatically free memory used by objects no longer needed -> Option B