Switch to Dark Mode

Java Memory Allocation

Here are 10 essential multiple-choice questions on Java Memory Allocation, covering key concepts.

Last Updated : Apr 28, 2025
Discuss
Comments

Question 1

In Java, which part of the memory is responsible for storing object instances?

  • A

    Stack Memory

  • B

    Heap Memory

  • C

    Method Area


  • D

    Native Memory

Question 2

Which of the following describes the purpose of the Stack Memory in Java?

  • A

    Stores global variables


  • B

    Stores references to objects and local variables

  • C

    Stores the JVM class files

  • D

    Stores object data and arrays


Question 3

How does Java handle memory management for objects that are no longer referenced?

  • A

    Objects are deleted manually


  • B

    Objects are automatically moved to disk

  • C

    Objects are moved to Stack Memory

  • D

    Objects are marked for garbage collection

Question 4

Which of the following is true about Garbage Collection (GC) in Java?


  • A

    GC is manual, and developers must call it explicitly

  • B

    GC is used to clean unused classes only

  • C

    GC automatically frees up memory by removing unreferenced objects

  • D

    GC occurs only when the system memory is full


Question 5

Which method is used to explicitly request garbage collection in Java?


  • A

    System.gc()

  • B

    Object.releaseMemory()

  • C

    GarbageCollector.run()

  • D

    MemoryManager.cleanup()

Question 6

Where does the Method Area in Java store class-level information?

  • A

    Heap Memory

  • B

    Stack Memory

  • C

    The JVM's permanent generation

  • D

    The ClassLoader

Question 7

What happens when an object is created in Java?


  • A

    The object is created in Stack Memory


  • B

    The object is created in Heap Memory

  • C

    The object is created in Method Area

  • D

    The object is created in the CPU register

Question 8

In Java, how is Stack Memory used during method execution?

  • A

    Stack Memory stores class variables

  • B

    Stack Memory is used for allocating objects

  • C

    Stack Memory is used to store method calls and local variables

  • D

    Stack Memory is used to store garbage objects

Question 9

Which of the following statements is true about Heap Memory in Java?


  • A

    Heap Memory is shared by all threads


  • B

    Heap Memory is only used by local methods


  • C

    Objects in Heap Memory are automatically deallocated when the method ends

  • D

    Heap Memory is used to store static variables


Question 10

How does Java handle memory allocation for primitive types such as int or char?

  • A

    They are stored in Heap Memory

  • B

    They are stored in Stack Memory

  • C

    They are stored in the Method Area


  • D

    They are allocated in Permanent Generation

There are 10 questions to complete.

Take a part in the ongoing discussion