0% found this document useful (0 votes)
4K views4 pages

JAVA MCQ-1-with Answers

The document discusses various components of the Java programming language environment including the JVM, JDK, JIT, and JRE. It provides explanations and identifies the correct components for different tasks: the JDK is used to compile, debug, and execute Java programs; the JVM converts bytecode to machine code and provides core functions; the JIT optimizes bytecode; and the JRE provides a platform to execute Java programs. The document also contains multiple choice questions about Java concepts such as the platform independence of Java, valid identifiers for the main method, file extensions, and more.

Uploaded by

Sri Sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4K views4 pages

JAVA MCQ-1-with Answers

The document discusses various components of the Java programming language environment including the JVM, JDK, JIT, and JRE. It provides explanations and identifies the correct components for different tasks: the JDK is used to compile, debug, and execute Java programs; the JVM converts bytecode to machine code and provides core functions; the JIT optimizes bytecode; and the JRE provides a platform to execute Java programs. The document also contains multiple choice questions about Java concepts such as the platform independence of Java, valid identifiers for the main method, file extensions, and more.

Uploaded by

Sri Sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Which component is used to compile, debug and execute java program?

a) JVM
b) JDK
c) JIT
d) JRE
View Answer
Answer: b
Explanation: JDK is core component of Java Environment and provides all the tools, executables
and binaries required to compile, debug and execute a Java Program.
2. Which component is responsible for converting bytecode into machine specific code?
a) JVM
b) JDK
c) JIT
d) JRE
View Answer
Answer: a
Explanation: 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.
3. Which component is responsible to run java program?
a) JVM
b) JDK
c) JIT
d) JRE
View Answer

Answer: d
Explanation: JRE is the implementation of JVM, it provides platform to execute java programs.
4. Which component is responsible to optimize bytecode to machine code?
a) JVM
b) JDK
c) JIT
d) JRE
View Answer
Answer: c
Explanation: JIT optimizes bytecode to machine specific language code by compiling similar
bytecodes at same time.This reduces overall time taken for compilation of bytecode to machine
specific language.
5. Which statement is true about java?
a) Platform independent programming language
b) Platform dependent programming language
c) Code dependent programming language
d) Sequence dependent programming language
View Answer
Answer: a
Explanation: Java is called ‘Platform Independent Language’ as it primarily works on the
principle of ‘compile once, run everywhere’.
6. Which of the below is invalid identifier with main method?
a) public
b) static
c) private
d) none of the above
View Answer
Answer: c
Explanation: main method cannot be private as it is invoked by external method. Other identifier
are valid with main method.
7. What is the extension of java code files?
a) .class
b) .java
c) .txt
d) .js
View Answer
Answer: b
Explanation: Java files have .java extension.
8. What is the extension of compiled java classes?
a) .class
b) .java
c) .txt
d) .js
View Answer
Answer: a
Explanation: The compiled java files have .class extension.
9. How can we identify whether a compilation unit is class or interface from a .class file?
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
View Answer

Answer: a
Explanation: 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.
10. What is use of interpreter?
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
View Answer
Answer: b
Explanation: Interpreters read high level language (interprets it) and execute the program.
Interpreters are normally not passing through byte-code and jit compilation.
11.Which of these keywords is used to make a class?
a) class
b) struct
c) int
d) none of the mentioned
View Answer

Answer: a
Explanation: None.
12. The Java interpreter is used for the execution of the source code.
True False
Ans: a.
13) On successful compilation a file with the class extension is created.
a) True b) False
Ans: a.
14) The Java source code can be created in a Notepad editor.
a) True b) False
Ans: a.
15) The Java Program is enclosed in a class definition.
a) True b) False
Ans: a.
16) What declarations are required for every Java application?
Ans: A class and the main( ) method declarations.
17) What are the two parts in executing a Java program and their purposes?
Ans: Two parts in executing a Java program are: Java Compiler and Java Interpreter. The Java
Compiler is used for compilation and the Java Interpreter is used for execution of the application
18) What is the return type of program’s main( ) method?
Ans : void
19) What is the argument type of program’s main( ) method?
Ans : string array.
20) Which characters are as first characters of an identifier?
Ans : A – Z, a – z, _ ,$
21) What are different comments?
Ans : 1) // -- single line comment 2) /* -- */ multiple line comment 3) /** -- */ documentation
22 Java is associated with _______ programming Language
A) Oak
B) Basic
C) C
D) Perl
Ans: A
23) A compiler converts the Java program into an intermediate language representation called
A)bytecode
B)byte
C)byteclass
D)bytejava
Ans: A
24)  Java platform consists of JVM and a package of readymade software components this
package is known as ________.
A) Java API
B) JVM API
C) JM API
D) API
Ans: A

25) Who is known as father of Java Programming Language? 


A.James Gosling B.M. P Java C. Charel Babbage D. Blais Pascal
Answer : Option A

You might also like