Mphasis Previous Years Solved Sample Placement Papers
-
Which of the following is responsible for converting bytecode into machine code?
a) JDK
b) JRE
c) JVM
d) Java Compiler
Ans: c) JVM -
What does JDK include?
a) Only a compiler
b) Only a runtime environment
c) Both a compiler and a runtime environment
d) None of the above
Ans: c) Both a compiler and a runtime environment -
Which of the following is NOT a part of the JRE?
a) Bytecode verifier
b) Classloader
c) Java Compiler
d) Java API classes
Ans: c) Java Compiler -
What is the primary function of JRE?
a) Compilation
b) Debugging
c) Execution
d) Development
Ans: c) Execution -
Can you run a Java program without JRE?
a) Yes
b) No
Ans: b) No -
Is JVM platform-independent?
a) Yes
b) No
Ans: a) Yes -
Which operator is used to perform bitwise "AND" operation?
a) &&
b) &
c) |
d) ||
Ans: b) & -
What does the == operator compare in Java objects?
a) Values
b) References
c) Hash codes
d) Fields
Ans: b) References -
Which operator is used for logical "AND" operation?
a) &&
b) &
c) ||
d) |
Ans: a) && -
Which of the following is a unary operator?
a) +
b) -
c) !
d) All of the above
Ans: d) All of the above -
Which operator has the highest precedence?
a) +
b) *
c) ()
d) &&
Ans: c) () -
What is the output of the expression true || false?
a) true
b) false
c) null
d) 0
Ans: a) true -
Which of the following is not a primitive data type in Java?
a) byte
b) String
c) double
d) short
Ans: b) String -
What is the default value of the int data type?
a) 0
b) 1
c) null
d) Undefined
Ans: a) 0 -
Which of the following data types can store a floating-point number?
a) int
b) byte
c) double
d) char
Ans: c) double -
Which data type can store a single character?
a) String
b) byte
c) char
d) int
Ans: c) char -
How many bits does the long data type use?
a) 8
b) 16
c) 32
d) 64
Ans: d) 64 -
What's the main difference between int and Integer in Java?
a) No difference
b) Integer can store larger values than int
c) int is a primitive data type, while Integer is a class
d) int can be null, while Integer cannot
Ans: c) int is a primitive data type, while Integer is a class -
Which loop construct in Java is best suited when the number of iterations is known?
a) for loop
b) while loop
c) do-while loop
d) break statement
Ans: a) for loop -
What is the purpose of the continue statement in a loop?
a) To exit the loop immediately
b) To skip the current iteration and move to the next iteration
c) To terminate the program
d) To execute a specific block of code
Ans: b) To skip the current iteration and move to the next iteration -
Which loop construct in Java is best suited when the number of iterations is unknown?
a) for loop
b) while loop
c) do-while loop
d) none
Ans: b) while loop