Skip to content
Sharp

Memory Management · interview question

Why does a reference variable in Java memory management matter in this design?

Multiple choiceMediumchapter-14-curatedpremiummemory-managementstack-vs-heap
Choose one answer
Answer and explanation

Correct answer

A. To point to objects stored on the heap.

Why

A reference variable in Java serves as a pointer to an object stored on the heap. The reference itself resides on the stack, while the actual object data is stored on the heap, allowing dynamic access to complex data structures.

Test yourself on Memory Management

A free test with instant, explained results. No account needed.

Start free test
All Memory Management questions →