Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of System.out.println(Math.sqrt(16));?
1) 4
2) 8
3) 2
4) None of the above
Answer : 4
What is the output of System.out.println("Hello" + "World");?
1) Hello World
2) HelloWorld
3) Hello+World
4) None of the above
Answer : HelloWorld
Which of the following is true about the Java Collections Framework?
1) It is a set of classes and interfaces.
2) It allows storage of objects in a single data structure.
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
Which of the following is used to read user input in Java?
1) Scanner
2) InputStream
3) BufferedReader
4) None of the above
Answer : Scanner
What is the output of System.out.println(1 + 2 + "3");?
1) 33
2) 6
3) 12
4) None of the above
Answer : 33
Which of the following interfaces does not extend Collection?
1) List
2) Set
3) Queue
4) Map
Answer : Map
Which of the following is not a feature of Java?
1) Platform-independent
2) Object-oriented
3) Use of pointers
4) Automatic garbage collection
Answer : Use of pointers
What is the output of System.out.println(5 & 3);?
1) 1
2) 3
3) 7
4) None of the above
Answer : 1
Which of the following is not a valid constructor in Java?
1) public MyClass() {}
2) MyClass() {}
3) MyClass(int a) {}
4) None of the above
Answer : None of the above
What is the output of System.out.println(10 << 1);?
1) 20
2) 5
3) 10
4) None of the above
Answer : 20