Skip to content
Sharp

JVM & runtime interview questions

Memory areas, class loading, JIT, garbage collection.

4 questions with answers and explanations · 3 flashcards

Key ideas

  • Objects live on the heap; each thread has a stack of frames holding locals and references.
  • Class lifecycle: loading → linking (verify, prepare, resolve) → initialization (static initializers run once).
  • Construction order: superclass first. Static blocks run at class initialization; instance initializers run before the constructor body.
  • The JIT compiles hot bytecode to native code at runtime.

Questions

  1. Where do Java objects and local variables live?Multiple choiceEasy
  2. What does the JVM's JIT compiler do?Multiple choiceMedium
  3. Put the phases a class goes through before it can be used in order.OrderingHard
  4. What does new Child(); print?What does this code output?Hard