Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of System.out.println(10 << 2);?
1) 20
2) 40
3) 80
4) Error
Answer : 40
What is the use of the `this` keyword in Java?
1) To refer to the current object
2) To refer to a method in the class
3) To refer to a constructor in the class
4) All of the above
Answer : To refer to the current object
What is the output of System.out.println(10 != 5);?
1) true
2) false
3) Error
4) None of the above
Answer : true
Which of the following is used to create a custom exception in Java?
1) Extending the Exception class
2) Extending the RuntimeException class
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println("Hello".toUpperCase());?
1) HELLO
2) hello
3) Error
4) None of the above
Answer : HELLO
Which of the following can be used to implement polymorphism in Java?
1) Method overloading
2) Method overriding
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(5 & 3);?
1) 1
2) 2
3) 5
4) None of the above
Answer : 1
What is the output of System.out.println("Java".equals("JAVA"));?
1) true
2) false
3) Error
4) None of the above
Answer : false
What is the use of the `super` keyword in Java?
1) To call the parent class constructor
2) To call the parent class method
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
What is the output of System.out.println(15 >> 2);?
1) 3
2) 4
3) 5
4) Error
Answer : 3