Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of System.out.println(15 % 4);?
1) 3
2) 4
3) 1
4) None of the above
Answer : 3
Which of the following is a marker interface in Java?
1) Serializable
2) Cloneable
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println("Hello World".indexOf("o"));?
1) 4
2) 7
3) 6
4) None of the above
Answer : 4
Which of the following keywords is used to define an interface in Java?
1) interface
2) implements
3) class
4) None of the above
Answer : interface
What is the output of System.out.println(1 + 2 + "3");?
1) 33
2) 6
3) 123
4) None of the above
Answer : 33
Which of the following is not a valid type in Java?
1) int
2) float
3) number
4) double
Answer : number
What is the output of System.out.println(10 >> 2);?
1) 2
2) 2.5
3) 40
4) None of the above
Answer : 2
Which of the following collections maintains the insertion order?
1) HashMap
2) HashSet
3) ArrayList
4) None of the above
Answer : ArrayList
What is the output of System.out.println("Java".toUpperCase());?
1) JAVA
2) java
3) JaVa
4) None of the above
Answer : JAVA
Which of the following is used to create an anonymous inner class in Java?
1) new ClassName()
2) new ClassName(){}
3) ClassName()
4) None of the above
Answer : new ClassName(){}