Here are 10 essential multiple-choice questions on Java Memory Allocation, covering key concepts.
Question 1
In Java, which part of the memory is responsible for storing object instances?
Stack Memory
Heap Memory
Method Area
Native Memory
Question 2
Which of the following describes the purpose of the Stack Memory in Java?
Stores global variables
Stores references to objects and local variables
Stores the JVM class files
Stores object data and arrays
Question 3
How does Java handle memory management for objects that are no longer referenced?
Objects are deleted manually
Objects are automatically moved to disk
Objects are moved to Stack Memory
Objects are marked for garbage collection
Question 4
Which of the following is true about Garbage Collection (GC) in Java?
GC is manual, and developers must call it explicitly
GC is used to clean unused classes only
GC automatically frees up memory by removing unreferenced objects
GC occurs only when the system memory is full
Question 5
Which method is used to explicitly request garbage collection in Java?
System.gc()
Runtime.gc()
GarbageCollector.run()
MemoryManager.cleanup()
Question 6
Where does the Method Area in Java store class-level information?
Heap Memory
Stack Memory
The JVM's permanent generation
The ClassLoader
Question 7
What happens when an object is created in Java?
The object is created in Stack Memory
The object is created in Heap Memory
The object is created in Method Area
The object is created in the CPU register
Question 8
In Java, how is Stack Memory used during method execution?
Stack Memory stores class variables
Stack Memory is used for allocating objects
Stack Memory is used to store method calls and local variables
Stack Memory is used to store garbage objects
Question 9
Which of the following statements is true about Heap Memory in Java?
Heap Memory is shared by all threads
Heap Memory is only used by local methods
Objects in Heap Memory are automatically deallocated when the method ends
Heap Memory is used to store static variables
Question 10
How does Java handle memory allocation for primitive types such as int or char?
They are stored in Heap Memory
They are stored in Stack Memory
They are stored in the Method Area
They are allocated in Permanent Generation
There are 10 questions to complete.