Java - Interview Questions and Answers on Compiler / Interpreter

Q1.  Is JVM, a compiler or interpreter ?

Ans. Its an interpretor.

Q2.  What is Java bytecode ?

Ans. “Java bytecode” is the usual name for the machine language of the Java Virtual
Machine. Java programs are compiled into Java bytecode, which can then be executed
by the JVM.

Q3. Is Java a compiler or an Interpreter ?

Ans. Its both compiler as well as Interpreter.

Q4.  Why is Java considered Portable Language ?

Ans. Java is a portable-language because without any modification we can use Java byte-code in any platform(which supports Java). So this byte-code is portable and we can use in any other major platforms.

Q5.  How Java provide high Performance ?

Ans. Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor.

Q6.  What is Java bytecode ?

Ans. Java bytecode is the instruction set of the Java virtual machine. Each bytecode is composed by one, or two bytes that represent the instruction, along with zero or more bytes for passing parameters.

Q7.  Is JVM a overhead ? 

Ans. Yes and No. JVM is an extra layer that translates Byte Code into Machine Code. So Comparing to languages like C, Java provides an additional layer of translating the Source Code.

C++ Compiler - Source Code --> Machine Code
Java Compiler - Source Code --> Byte Code   ,  JVM - Byte Code --> Machine Code

Though it looks like an overhead but this additional translation allows Java to run Apps on all platforms as JVM provides the translation to the Machine code as per the underlying Operating System.