This set of Java Multiple Choice Questions & Answers (MCQs) on “JDK-JRE-JIT-JVM”.
1. Which component is used to compile, debug and execute java program? Answer: b 2. Which component is responsible for converting bytecode into machine specific code? Answer: a 3. Which component is responsible to run java program? Answer: d 4. Which component is responsible to optimize bytecode to machine code? Answer: c 5. Which statement is true about java? Answer: a 6. Which of the below is invalid identifier with the main method? Answer: c 7. What is the extension of java code files? Answer: b 8. What is the extension of compiled java classes? Answer: a 9. How can we identify whether a compilation unit is class or interface from a .class file? Answer: a 10. What is use of interpreter? Answer: b
a) JVM
b) JDK
c) JIT
d) JRE
Clarification: JDK is a core component of Java Environment and provides all the tools, executables and binaries required to compile, debug and execute a Java Program.
a) JVM
b) JDK
c) JIT
d) JRE
Clarification: JVM is responsible to converting bytecode to the machine specific code. JVM is also platform dependent and provides core java functions like garbage collection, memory management, security etc.
a) JVM
b) JDK
c) JIT
d) JRE
Clarification: JRE is the implementation of JVM, it provides platform to execute java programs.
a) JVM
b) JDK
c) JIT
d) JRE
Clarification: JIT optimizes bytecode to machine specific language code by compiling similar bytecodes at the same time. This reduces overall time taken for compilation of bytecode to machine specific language.
a) Platform independent programming language
b) Platform dependent programming language
c) Code dependent programming language
d) Sequence dependent programming language
Clarification: Java is called ‘Platform Independent Language’ as it primarily works on the principle of ‘compile once, run everywhere’.
a) public
b) static
c) private
d) final
Clarification: main method cannot be private as it is invoked by external method. Other identifier are valid with main method.
a) .class
b) .java
c) .txt
d) .js
Clarification: Java files have .java extension.
a) .class
b) .java
c) .txt
d) .js
Clarification: The compiled java files have .class extension.
a) Java source file header
b) Extension of compilation unit
c) We cannot differentiate between class and interface
d) The class or interface name should be postfixed with unit type
Clarification: The Java source file contains a header that declares the type of class or interface, its visibility with respect to other classes, its name and any superclass it may extend, or interface it implements.
a) They convert bytecode to machine language code
b) They read high level code and execute them
c) They are intermediated between JIT and JVM
d) It is a synonym for JIT
Clarification: Interpreters read high level language (interprets it) and execute the program. Interpreters are normally not passing through byte-code and jit compilation.