Java Zero to All All questionsPractise free
Interview questions › Interview Rapid-Fire — Top Q&A › JVM Internals — Top Interview Q&A

How does the JIT Compiler improve performance?

Level II · JuniorJVM Internals — Top Interview Q&A
Short answer

The JVM starts by interpreting bytecode, and the JIT compiles frequently executed (hot) methods and loops to native machine code at runtime.

Explanation

HotSpot uses tiered compilation: C1 (client) compiles quickly with light optimization, then C2 (server) recompiles the hottest code with aggressive optimizations. Because it profiles the actual running workload, the JIT applies speculative optimizations — inlining, loop unrolling, dead-code elimination, escape analysis — that a static compiler cannot, and it deoptimizes back to the interpreter if a speculative assumption (e.g. a monomorphic call site) is later violated.

Common mistakes
  • Saying Java is interpreted only.
  • Not knowing C1, C2 and tiered compilation.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for JVM Internals — Top Interview Q&A.

Practise free

More on JVM Internals — Top Interview Q&A