Memory Management
1.Which area of the JVM memory is primarily responsible for storing all objects and arrays created at runtime?
-
A. Stack
-
B. Heap
-
C. Method Area
-
D. PC Register
Heap
Heap
2.What is the main responsibility of the Garbage Collector in Java?
-
A. To allocate memory for new objects.
-
B. To reclaim memory occupied by objects that are no longer referenced.
-
C. To encrypt data stored in memory.
-
D. To manage thread synchronization.
To reclaim memory occupied by objects that are no longer referenced.
To reclaim memory occupied by objects that are no longer referenced.
3.When does an object become eligible for garbage collection?
-
A. When its finalize() method is called.
-
B. When it is no longer referenced by any active part of the program.
-
C. When the JVM runs out of memory.
-
D. When the program explicitly calls System.gc().
When it is no longer referenced by any active part of the program.
When it is no longer referenced by any active part of the program.
4.Which type of garbage collector in Java is designed for low pause times, making it suitable for interactive applications?
-
A. Serial GC
-
B. Parallel GC
-
C. G1 GC (Garbage-First Garbage Collector)
-
D. Concurrent Mark-Sweep (CMS) GC
G1 GC (Garbage-First Garbage Collector)
G1 GC (Garbage-First Garbage Collector)
5.What is a "memory leak" in Java?
-
A. When an application explicitly frees memory before it's needed.
-
B. When an application unnecessarily holds onto references to objects that are no longer needed, preventing them from being garbage collected.
-
C. When the operating system fails to allocate enough memory to the JVM.
-
D. When the JVM crashes due to insufficient memory.
When an application unnecessarily holds onto references to objects that are no longer needed, preventing them from being garbage collected.
When an application unnecessarily holds onto references to objects that are no longer needed, preventing them from being garbage collected.