Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of System.out.println(10 & 5);?
1) 0
2) 1
3) 5
4) None of the above
Answer : Option 1
Which of the following methods is used to read input from the console in Java?
1) Scanner.nextLine()
2) BufferedReader.read()
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(7 >> 1);?
1) 3
2) 7
3) 14
4) None of the above
Answer : 3
Which of the following statements is true about method overriding in Java?
1) It allows subclass to provide a specific implementation of a method.
2) It can change the return type of the method.
3) It can be used to access superclass methods.
4) None of the above
Answer : It allows subclass to provide a specific implementation of a method.
What is the output of System.out.println("5" * 2);?
1) 10
2) 55
3) Error
4) None of the above
Answer : Error
Which of the following is used to handle errors in Java?
1) try-catch
2) throws
3) throw
4) All of the above
Answer : All of the above
What is the output of System.out.println("abc".equals("abc"));?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is true about the `final` keyword in Java?
1) It can be used with variables, methods, and classes.
2) It can be used to prevent method overriding.
3) It can be used to prevent inheritance.
4) All of the above
Answer : All of the above
What is the output of System.out.println(3 + 2 * 2);?
1) 7
2) 10
3) 8
4) None of the above
Answer : 7
Which of the following methods is used to convert a string to an integer?
1) Integer.parseInt()
2) String.toInteger()
3) convertToInt()
4) None of the above
Answer : Integer.parseInt()