🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.On the stack, with s
  2. B.On the heap; s on the stack holds a reference to it
  3. C.In Metaspace
  4. 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 →