Java Garbage Collection MCQ Questions and Answers
Q. What is the primary purpose of garbage collection in Java?
A. To automatically manage memory allocation and deallocationB. To improve program performance by optimizing memory usage
C. To ensure that all objects are properly destroyed before program termination
D. To prevent memory leaks and improve memory efficiency
Q. What is a garbage collector in Java?
A. It is a low-level utility class in the Java APIB. It is a built-in feature of the Java Virtual Machine (JVM)
C. It is a separate process that runs alongside the JVM
D. It is a developer-defined method for memory management
Q. What is a garbage collection algorithm?
A. It is a set of rules followed by the garbage collector to manage memoryB. It defines the strategy used by the garbage collector to identify unused objects
C. It determines the order in which objects are allocated memory
D. It specifies how the garbage collector reclaims memory from unused objects
Q. What is a garbage collection cycle?
A. The process of allocating memory for new objectsB. The sequence of steps followed by the garbage collector
C. The time between the creation of an object and its destruction
D. The interval between two consecutive garbage collection runs
Q. What is a garbage collection policy?
A. It defines the criteria for selecting objects to be garbage collectedB. It determines the frequency of garbage collection cycles
C. It specifies the algorithm used by the garbage collector
D. It defines how memory is allocated to objects
Q. What is a garbage collection root?
A. It is a special type of object that is never garbage collectedB. It serves as a starting point for the garbage collector's traversal
C. It is a reference to an object that is always reachable
D. It is a data structure used by the garbage collector to track objects
Q. What is a garbage collection trace?
A. It is a report generated after each garbage collection cycleB. It is a visual representation of the garbage collector's traversal
C. It is a log of all objects that were garbage collected
D. It is a record of all objects reachable from the roots
Q. What is a garbage collection pause?
A. The time taken by the garbage collector to complete a cycleB. The interval during which the application is paused for garbage collection
C. The duration between the start of garbage collection and the resumption of application threads
D. The time taken by the garbage collector to identify all unused objects
Q. What is a garbage collection heap?
A. It is a data structure used by the garbage collector to store objectsB. It refers to the portion of memory managed by the garbage collector
C. It is a separate memory area used exclusively for garbage collection
D. It is a stack-like structure used for temporary object storage
Q. What is a garbage collection generation?
A. It is a group of objects based on their ageB. It refers to the number of times an object has been garbage collected
C. It is a category of objects based on their memory usage
D. It is a classification of objects based on their creation time