Java Compilation Process, Bytecode, JVM and Features of Java (ICSE Class 10)
Updated 17 October 2026 · Fact-checked
A Java programmer writes source code (.java). The compiler (javac) checks it and converts it into bytecode (.class), which is not tied to any machine. The Java Virtual Machine (JVM) on the user's computer turns bytecode into machine-level object code and runs it. Because the same bytecode runs on any system with a JVM, Java is platform independent.
Follow the arrows: javac turns .java into machine-independent bytecode, and the JVM on each computer converts it to machine code, so Java runs anywhere.
Illustration drawn for QuestionBuddy.
Understand Java Compilation Process, JVM and Features
Types of Java programs. An application is a stand-alone program that runs on the computer on its own and starts from the main method (for example a program run in BlueJ). An applet is a small program embedded in a web page and run by a browser or an applet viewer; it has no main method.
Three forms of a program.
- Source code: the program as the programmer writes it, in the high-level Java language, saved in a file with the extension
.java. - Bytecode: the intermediate, machine-independent code produced by the Java compiler, saved in a
.classfile. - Object code: the machine-level code (binary instructions) that the processor of a particular computer can execute directly; the JVM produces it from bytecode when the program runs.
Java Virtual Machine (JVM). A software layer that reads bytecode, converts it to machine code of the computer it is running on and executes it. Every platform has its own JVM, but all of them accept the same bytecode.
Steps of the compilation process.
1. Write the program (source code) and save it with the class name and .java.
2. The compiler javac checks the syntax. If errors exist they are reported and no bytecode is created.
3. If there are no errors, bytecode is created in a .class file.
4. The JVM loads the bytecode, converts it to machine code and executes it. The output appears.
Features of Java (those named in the syllabus plus the usual extras): *simple* (no pointers, familiar syntax), *robust* (strong memory management and exception handling, catches many errors early), *secure* (no direct memory access, bytecode is checked before it runs), *object oriented* (programs are built from classes and objects), *platform independent* (compile once, run anywhere there is a JVM).
Note the order: source code, then bytecode, then object code. Platform independence comes from bytecode, not from source code.
Java Compilation Process, JVM and Features: key facts
- Order of code forms
Source code .java Bytecode .class Object code machine code - The compiler makes bytecode; the JVM makes object code.
- Who does what
Programmer writes source code Compiler (javac) source to bytecode JVM bytecode to machine code and runs it - A common 3-mark question.
- Application vs applet
- Application: stand-alone, has main() | Applet: runs inside a web page, no main()
- Both are written in Java.
- Features of Java
- Simple
- Robust
- Secure
- Object oriented
- Platform independent
- Give a one-line reason for each.
How to answer Java Compilation Process, JVM and Features questions
Use this routine for definition and flow questions on compilation.
- 1Start from the source code and give its extension .java.
- 2Name the compiler (javac) and say it produces bytecode (.class), or error messages if the syntax is wrong.
- 3Say that the JVM executes the bytecode by converting it to machine code (object code) of that computer.
- 4For platform independence, always mention that bytecode is the same for every system and only the JVM differs.
- 5For a feature question, give the feature name and one reason, not just the name.
Java Compilation Process, JVM and Features in real life
The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.
Bytecode as a common language
Suppose a book is written in English (source code), translated once into a simple common language (bytecode), and each country has its own reader who speaks that common language and reads it out in the local language (JVM producing object code).
Why does the same translated book work in every country, and what has to be installed in each country?
Try it first, then show the solutionSolution
- The translated book (bytecode) is the same everywhere, so no new translation is needed.
- Only a reader (JVM) for that country must be present.
Answer: Because bytecode is machine independent; each system needs only its own JVM.
Memory hook: Compile once, run anywhere.
Tricks to remember Java Compilation Process, JVM and Features
Short memory aids. Say each one aloud once, then use it on a question the same day.
S-B-O
Source, Bytecode, Object: the program becomes less human and more machine at each step.
Use it when: Ordering questions.
javac makes, java runs
javac compiles (makes the .class file); the JVM runs it.
Use it when: Who does what.
SRS-OP
Simple, Robust, Secure, Object oriented, Platform independent.
Use it when: Listing the features.
Java Compilation Process, JVM and Features: solved examples
Ordered from board level to HOTS. Try each one before you open the solution.
Example 1: Define the terms · 3 marks · Short answerBoard level
Define: (i) source code (ii) bytecode (iii) JVM.
Try it first, then show the solutionSolution
- Source code: the program written by the programmer in Java, saved with the extension .java. (1 mark)
- Bytecode: the machine-independent intermediate code produced by the compiler and stored in a .class file. (1 mark)
- JVM: the Java Virtual Machine, software that converts bytecode into machine code and executes it. (1 mark)
Answer: Source code is the .java program; bytecode is the compiler output (.class); JVM executes the bytecode on a given machine.
Example 2: Why platform independent · 3 marks · Short answerHarder board level
A program is compiled on a Windows computer. Its .class file is copied to a computer with a different operating system that has Java installed. Will it run? Explain which Java feature and which component make this possible. (3 marks)
Try it first, then show the solutionSolution
- Yes, it will run. (1 mark)
- The compiler produced bytecode, which does not depend on any machine or operating system. (1 mark)
- The JVM of the second computer converts that bytecode into its own machine code; this is the platform independence feature of Java. (1 mark)
Answer: It runs, because bytecode is machine independent and the local JVM translates it: platform independence.
Example 3: Applet or application · 3 marks · Short answerHarder board level
A student has a program that starts with public static void main and another that is placed inside a web page. Name the type of each program, and give the purpose of each.
Try it first, then show the solutionSolution
- An application is a stand-alone program that runs by itself and begins at main(); an applet has no main() and is run inside a web page by a browser or applet viewer. (1 mark)
- An application can be run directly from the computer; an applet must be embedded in a web page. (1 mark)
- Purpose: applications are general programs such as calculators; applets were meant to add small interactive parts to web pages. (1 mark)
Answer: Application: stand-alone, uses main(). Applet: embedded in a web page, no main().
Example 4: What happens to a program with an error · 4 marks · Case-basedHOTS / competency
A student saves a program as Test.java, compiles it and the compiler reports a syntax error. State, in order, what files exist after compilation, and what must be done before the JVM can run the program.
Try it first, then show the solutionSolution
- The source file Test.java exists. (1 mark)
- Because the compiler found an error, no bytecode was created: there is no Test.class (assuming no earlier successful compile). (1 mark)
- The student must correct the error in the source code and compile again. (1 mark)
- Only after a successful compile does the .class file exist and the JVM can load and run it. (1 mark)
Answer: Only Test.java exists; the error must be fixed and the program recompiled to get Test.class before the JVM can run it.
Example 5: Reasons for the features · 4 marks · Short answerHarder board level
Match each Java feature with the reason: (i) simple (ii) robust (iii) secure (iv) object oriented. Reasons: A. programs are built from classes and objects B. strong error checking at compile time and run time C. no direct access to memory by the programmer D. familiar syntax and no pointers.
Try it first, then show the solutionSolution
- Simple has familiar syntax and no pointers: D. (1 mark)
- Robust is about strong error checking and handling: B. (1 mark)
- Secure is about not letting programs reach memory directly: C. (1 mark)
- Object oriented means classes and objects: A. (1 mark)
Answer: (i) D, (ii) B, (iii) C, (iv) A
Where students lose marks in Java Compilation Process, JVM and Features
The slips examiners see most often, and what to write instead.
Mistake: Saying the compiler produces machine code
javac produces bytecode; machine-level object code is produced by the JVM at run time.
Wrong working
javac converts the source code into machine code.
Right working
javac converts the source code into bytecode; the JVM converts bytecode into machine code.
Do this: Remember S-B-O in order.
Usually costs: 1 mark
Mistake: Calling bytecode "object code"
The syllabus lists them as separate terms: bytecode is machine independent, object code is machine specific.
Wrong working
Bytecode is the machine-level code that the processor executes.
Right working
Bytecode is an intermediate code for the JVM; object code is the machine-level code for one processor.
Do this: Add the words "machine independent" to bytecode.
Usually costs: 1 mark
Mistake: Listing features without reasons
A feature name alone is a half answer in a 2 or 3 mark question.
Wrong working
Java is simple, secure and robust.
Right working
Java is simple (familiar syntax, no pointers), secure (no direct memory access) and robust (strong error checking).
Do this: Add a bracket of reason after each name.
Usually costs: 1 mark
Exam tips
- Write the extensions: .java for source code and .class for bytecode; they are easy marks.
- Mention the JVM in every platform independence answer.
- For applet vs application, always mention main() and the web page.
- Keep the order source code, bytecode, object code in any process answer.
Practice questions on Java Compilation Process, JVM and Features
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQBoard level
Which sequence correctly shows the order in which a Java program changes form?
(a) bytecode, source code, object code (b) source code, object code, bytecode (c) source code, bytecode, object code (d) object code, bytecode, source codeHint
Compiler first, JVM second.
Answer
(c) source code, bytecode, object code
Q2 · 1 mark · Very short answerBoard level
What is the full form of JVM?
Hint
Three words.
Answer
Java Virtual Machine.
Q3 · 1 mark · Very short answerBoard level
Name the two types of Java programs.
Hint
One needs a browser.
Answer
Applications and applets.
Q4 · 4 marks · Long answerHarder board level
Explain the steps involved in the Java compilation process, from writing the program to getting the output.
Hint
Four steps: source, javac, bytecode, JVM.
Answer
The program is written as source code in a .java file. The compiler javac checks its syntax; if errors exist they are reported and compilation stops. If none exist, javac produces bytecode in a .class file. The JVM loads this bytecode, converts it to machine code (object code) of the computer and executes it, giving the output.
Q5 · 1 mark · Assertion-reasonHOTS / competency
Assertion (A): Java is called a platform independent language.
Reason (R): The Java compiler converts source code directly into machine code of the computer on which it is compiled.
(a) Both A and R are true and R is the correct explanation of A. (b) Both A and R are true but R is not the correct explanation of A. (c) A is true but R is false. (d) A is false but R is true.Hint
What does the compiler really produce?
Answer
(c) A is true; R is false because the compiler produces bytecode, not machine code, which is exactly why Java is platform independent.
Test your recall
Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.
1.Which program converts source code to bytecode?Show answer
The Java compiler (javac).
2.What does the JVM do?Show answer
Converts bytecode to machine code and executes it.
3.Which Java program has no main() method?Show answer
An applet.
4.Name two features of Java.Show answer
Any two of simple, robust, secure, object oriented, platform independent.
5.What is saved in a .class file?Show answer
Bytecode.
6.What happens if the source code has a syntax error?Show answer
The compiler reports it and does not create bytecode.
Java Compilation Process, JVM and Features: frequently asked questions
Is bytecode the same as object code?
No. Bytecode is the machine-independent code made by the compiler; object code is the machine-level code that a particular processor executes, made by the JVM.
Why is Java called platform independent?
Its compiler produces bytecode that is the same on every system, and each system has a JVM that runs that bytecode.
Do I need to know how the JVM is built?
No. At Class X you only need its definition and role in the compilation process.