Section_14_Garbage_Collection_Questions
Section_14_Garbage_Collection_Questions
Q1. In Java, which of the following is responsible for automatically reclaiming unused
memory?
• A) Garbage Collector
• B) JVM Optimizer
• C) Memory Manager
• D) System Cleaner
Q2. Which of the following methods can suggest the JVM to run the garbage collector?
• A) System.gc()
• B) Runtime.freeMemory()
• C) System.runGC()
• D) freeMemory()
Q4. What will happen if the finalize() method is called directly on an object?
• A) The object is immediately garbage collected
• B) finalize() executes, but garbage collection is not forced
• C) The object becomes eligible for garbage collection
• D) It causes a runtime error
Q9. What happens to an object that is no longer reachable from any live thread?
• A) It remains in memory indefinitely
• B) It is automatically garbage collected
• C) It causes a memory leak
• D) It is saved to disk
Q10. How does Java prevent the application from running out of memory?
• A) By stopping execution of threads
• B) By automatically collecting unreachable objects
• C) By converting unused memory to disk storage
• D) By increasing memory allocation