Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is not a loop structure in Java?
1) for
2) foreach
3) while
4) do-while
Answer : foreach
Which of the following statements is true regarding the `final` keyword?
1) A final variable can be changed.
2) A final method cannot be overridden.
3) Both 1 and 2
4) None of the above
Answer : A final method cannot be overridden.
What is the output of System.out.println(2 + 3 * 4);?
1) 14
2) 20
3) 14
4) None of the above
Answer : 14
Which of the following is true about the `volatile` keyword?
1) It ensures visibility of shared variables.
2) It prevents caching of variables.
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(1 + "2" + 3);?
1) 123
2) 6
3) Error
4) None of the above
Answer : 123
Which of the following is not a characteristic of Java?
1) Simple
2) Secure
3) Fast
4) Robust
Answer : Fast
What is the output of System.out.println(5 | 3);?
1) 7
2) 8
3) 5
4) None of the above
Answer : 7
Which of the following is true about constructors in Java?
1) They have the same name as the class.
2) They do not have a return type.
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(10 / 2 * 3);?
1) 15
2) 5
3) 20
4) None of the above
Answer : 15
Which of the following is a marker interface in Java?
1) Serializable
2) Cloneable
3) Remote
4) All of the above
Answer : All of the above