JVM & runtime · interview question
Where do Java objects and local variables live?
Multiple choiceEasy
Answer and explanation
Correct answer
A. Objects live on the heap; each thread's stack holds frames with local variables, including references to heap objects.
Why
The heap is shared and garbage-collected; stacks are per thread. (The JIT may avoid some heap allocations through escape analysis, but the language model is heap objects.)
Test yourself on JVM & runtime
A free test with instant, explained results. No account needed.