← Quiz: JVM Memory and Garbage Collection: all 10 questions
Quiz: JVM Memory and Garbage Collection · Question 1 of 10
Where does the object created by Student s = new Student(); inside a method live?
Where does the object created by Student s = new Student(); inside a method live?
- A.On the stack, with s
- B.On the heap; s on the stack holds a reference to it
- C.In Metaspace
- D.In the CPU registers
Answer & explanation
Correct answer: On the heap; s on the stack holds a reference to it
Objects always live on the heap. The local variable s is in the method's stack frame and stores only the reference.
Can you get the rest right without peeking?
Take the timed Quiz: JVM Memory and Garbage Collection quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →