Chap 02 - Introduction To Java
Chap 02 - Introduction To Java
Answer
There are two types of Java programs — Java Stand-Alone Applications and Java Applets.
Java Applets
Java applets are Java applications that run within a web browser. They are mainly used for
internet programming. The applet is capable of performing many tasks on a web page, such
as displaying graphics, playing sounds, and accepting user input.
Question 2
Answer
Java applications are platform independent, which means that Java applications can be run
on any platform. After Java source code is compiled, it is converted into bytecode. The
bytecode is then interpreted by the JVM. JVM can be installed on several different
operating systems such as Windows, UNIX, Macintosh, etc. JVM allows Java programs to
run on almost any computer regardless of its hardware configuration. Due to this factor,
Java is considered as a platform independent language.
Question 3
Answer
Question 4
Answer
Answer
In traditional compilation process, the machine language code generated by the compiler is
specific to the platform for which the source code is compiled. The executable file
generated for one platform like Windows will not work on other platforms like Macintosh.
In Java compilation process, the source code of a Java program is compiled to an
intermediate binary code called the Bytecode. This Bytecode is interpreted and executed by
JVM on the target platform. Bytecode is platform independent so the same Bytecode which
is generated for one platform like Windows will work on other platforms like Macintosh
without any modifications.
Question 6
Answer
JVM
JVM stands for the Java Virtual Machine. It is a virtual machine that runs Java programs
and can be installed on several different operating systems such as Windows, UNIX,
Macintosh etc. JVMs allow Java programs to run on almost any computer. A JVM
processes instructions similar to a physical processor. However, the Java code (with "java"
extension) must first be converted into Bytecode that the JVM understands.
JIT
JIT is the Just-In-Time compiler included in the JVM that compiles selected portions of the
Bytecode into executable codes to improve the execution performance.
Question 7
Answer
Answer
Compiler Interpreter
It displays the errors for the whole It displays the error one line at a time and
program together, after the only after fixing that error the control goes
compilation. to the next line.
Answer
It contains the Java source code of the program. It contains the Bytecode of the program.
Question 8
Answer
The programs written in Java are compiled into a machine language for a virtual computer
called Java Virtual Machine (JVM). The machine language for this special Java Virtual
Machine is called Java Bytecode. The Bytecode files are generated with the ".class"
extension.
Question 9
Answer
Bytecode and JVM makes Java programs platform independent. This is one of the most
important and powerful features of Java. The Bytecode of a Java program can be run on any
platform that has a corresponding JVM installed on it. No modifications to this Bytecode
are required. Hence, it is said that Java provides "Write once, run anywhere" capabilities.
Question 10
Answer