JAVA compiler translates source code into _______.
byte code
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.
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:
.java source files.The format of these output files is where the answer lies.
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.
| Input | Process | Output |
|---|---|---|
| Java Source Code (.java files) | Java Compiler (javac) |
Byte Code (.class files) |
Let's consider the other options provided:
Therefore, the correct output generated by the Java compiler from source code is byte code.
| 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. |
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.
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.
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”;
}
}
A java program that is embedded in HTML document and runs in the context of java capable browser is known as ______.
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
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: