All Exams Test series for 1 year @ ₹349 only
Question

JAVA compiler translates source code into _______.

The correct answer is

byte code

Understanding the Java Compilation Process

The Java programming language has a unique compilation process compared to many other languages. When you write a Java program, you create files with a .java extension. These files contain the human-readable instructions written in Java.

What Does the Java Compiler Do?

The primary role of the Java compiler (javac) is to take the Java source code and translate it into a format that can be understood by the Java Virtual Machine (JVM). This translation is a crucial step in making Java a portable language.

Let's look at the output of the Java compiler:

  • The compiler reads the .java source files.
  • It checks for syntax errors and performs various optimizations.
  • If there are no errors, it generates a new file for each class in the source code.

The format of these output files is where the answer lies.

The Output of the Java Compiler: Byte Code

The Java compiler translates the source code into byte code. Byte code is a set of instructions designed to be executed by the Java Virtual Machine (JVM). It is not machine code specific to any particular computer architecture. Instead, it's an intermediate representation that is the same regardless of the underlying operating system or hardware.

These byte code files have a .class extension.

The JVM then interprets or Just-In-Time (JIT) compiles the byte code into native machine code that the specific computer can execute.

Java Compilation Step
Input Process Output
Java Source Code (.java files) Java Compiler (javac) Byte Code (.class files)

Why Other Options are Incorrect

Let's consider the other options provided:

  • High language code: High-level language code is the source code itself (like the Java code you write). The compiler translates *from* a high-level language, not into another high-level language in this step.
  • Assembly code: Assembly code is a low-level language that is a symbolic representation of machine code instructions. While some compilers might translate high-level code into assembly code as an intermediate step before generating machine code, the standard Java compilation process translates source code directly into byte code, not assembly code.
  • Symbolic code: This term is quite general. While source code or even assembly code can be considered symbolic, the specific output of the Java compiler is termed 'byte code'. 'Symbolic code' isn't the precise or correct term for the compiler's output in this context.

Therefore, the correct output generated by the Java compiler from source code is byte code.

Revision Table: Java Compilation Key Terms

Term Description
Java Source Code Human-readable code written by developers (.java files).
Java Compiler (javac) Tool that translates source code into byte code.
Byte Code Intermediate, platform-independent code (.class files) executed by the JVM.
Java Virtual Machine (JVM) Abstract machine that executes Java byte code.
Machine Code Low-level instructions specific to a particular computer's processor.

Additional Information: The Role of JVM

The existence of byte code and the JVM is what makes Java's "Write Once, Run Anywhere" principle possible. The Java compiler creates the same byte code regardless of the operating system (Windows, macOS, Linux, etc.). Then, a specific implementation of the JVM for that operating system can execute the byte code.

The JVM acts as an interpreter for the byte code, or it uses a Just-In-Time (JIT) compiler to translate the byte code into native machine code on the fly for better performance.

Was this answer helpful?

Important Questions from Java

  1. Which of the following statement(s) is/are TRUE regarding Java Servelets?

    (a) A Java Servlet is a server-side component that runs on the webserver and extends the capabilities of a server.

    (b) A Servelet can use the user interface classes like AWT or Swing.

  2. What is the output of the following JAVA program?

    class Test

    {

    public static void main (String [ ] args)

    {

    Test obj = new Test ();

    obj.start ();

    }

    void start ()

    {

    String stra="do”;

    String strb = method (stra);

    System.out.print(“:” + stra + strb);

    }

    String method (String stra)

    {

    stra=stra+”good”;

    System.out.print (stra);

    return “good”;

    }

    }

  3. A java program that is embedded in HTML document and runs in the context of java capable browser is known as ______.

  4. Which of the following statement(s) is/are correct regarding java programming?

    I. Place a semicolon immediately after a method header

    II. Define a method outside the braces of a class definition

  5. Arrange the following applet life cycles methods in sequence 

    A. start() 

    B. paint() 

    C. init() 

    D. stop() 

    Choose the correct answer from the options given below:

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App