Skip to content
Exercises · Q1

Q.What is a program? Explain how Java source code becomes a running program, naming the roles of the compiler, bytecode and the JVM.

ChseodishaTextbookSubjectiveImportance★★★★★est
8% · 1/13 Questions
✓ Free question

What a program is. A computer cannot decide anything on its own — it only follows instructions. A program is an ordered set of such instructions, written in a programming language, that makes the computer perform a specific task. Writing these instructions is called programming.

Why we don't run source code directly. People write in a high-level language such as Java because machine language (0s and 1s) is impractical to write by hand. The human-readable text we type is the source code, saved in a .java file. The computer, however, cannot run this text directly, so Java uses two stages:

Stage 1 — Compilation. The compiler javac reads the source code and checks it for syntax (grammar) errors. If the code is correct, it translates it into bytecode, stored in a .class file. Bytecode is a special intermediate form that is not tied to any one kind of computer.

Stage 2 — Execution. The Java Virtual Machine (JVM) reads the bytecode and executes it on the actual computer, turning it into the machine's own instructions as it runs.

Why this design matters. Every type of computer runs its own JVM, but all JVMs understand the same bytecode. So a program compiled once will run on any machine that has a JVM — this is Java's famous "write once, run anywhere" platform independence.

✓Final answer

A program is an ordered set of instructions for a computer. In Java, the compiler (javac) converts the source code into bytecode, and the JVM executes that bytecode on the actual machine. Bytecode being platform-independent is what makes Java run on any computer with a JVM.

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.