Java MCQ: What is garbage collection in Java?
a) Manually deleting objects
b) Automatic memory management
c) Compacting memory
d) Allocating memory
Answer:
b) Automatic memory management
Explanation:
Garbage collection in Java is an automatic process where the JVM reclaims memory by deleting objects that are no longer referenced. This helps prevent memory leaks and reduces the need for manual memory management.
Understanding garbage collection is key to writing efficient Java applications that manage memory effectively.
Reference links:
https://www.rameshfadatare.com/learn-java-programming/
https://www.javaguides.net/p/java-tutorial-learn-java-programming.html