Question
Which statement about Heap vs Stack is the strongest interview answer?
- Heap vs Stack is mostly a naming style choice and has little effect on runtime or design.
- Heap vs Stack exists mainly to reduce the number of Java files in a project.
- Heap vs Stack matters only for frontend frameworks, not for core Java applications.
- Method call frames and local variables live on the stack, while objects usually live on the heap.
Hint
Start with the core rule behind Heap vs Stack.
Answer and rationale
Correct answer: D. Method call frames and local variables live on the stack, while objects usually live on the heap.
Method call frames and local variables live on the stack, while objects usually live on the heap. This is the base concept interviewers commonly test first.
Track: Java