Java Zero to All All questionsPractise free
Interview questions › Java Foundations — Zero to Basics › How Java Runs — JDK, JRE, JVM & Your First Program

What is bytecode, and how is it different from machine code?

Level I · BeginnerHow Java Runs — JDK, JRE, JVM & Your First Program
Short answer

Bytecode is the intermediate instruction set that javac produces -- compact, platform-independent instructions for the abstract JVM, stored in .class files.

Explanation

Machine code is the concrete instruction set of a specific physical CPU. Bytecode is not run directly by the CPU; the JVM interprets it and JIT-compiles the hot parts into real machine code at run time. You can inspect bytecode with `javap -c YourClass`.

Common mistakes
  • Calling bytecode 'machine code for Java' — it is CPU-independent instructions for the JVM.
  • Forgetting the JIT turns hot bytecode into real machine code at runtime.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for How Java Runs — JDK, JRE, JVM & Your First Program.

Practise free

More on How Java Runs — JDK, JRE, JVM & Your First Program