Learn JAVA MCQs
Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.
What is the output of System.out.println(Math.max(5, 10));?
1) 5
2) 10
3) 0
4) None of the above
Answer : 10
Which of the following statements is true about method overriding in Java?
1) The return type must be the same or a subtype.
2) The method name must be different.
3) The number of parameters must differ.
4) None of the above
Answer : The return type must be the same or a subtype.
Which of the following is true about interfaces in Java?
1) Interfaces can have constructors.
2) Interfaces can have default methods.
3) Interfaces cannot be extended.
4) None of the above
Answer : Interfaces can have default methods.
Which of the following is a feature of the Java programming language?
1) Multithreaded
2) Platform-independent
3) Both 1 and 2
4) None of the above
Answer : Both 1 and 2
Which of the following is the correct way to declare a variable in Java?
1) int 1x = 10;
2) int x = 10;
3) int x = "10";
4) None of the above
Answer : int x = 10;
What is the output of System.out.println(5 == 5);?
1) true
2) false
3) 1
4) 0
Answer : true
Which of the following is true about method overloading in Java?
1) The methods must have different names.
2) The methods must have different return types.
3) The methods must have different parameter lists.
4) None of the above
Answer : The methods must have different parameter lists.
Which of the following is true about an abstract class in Java?
1) An abstract class cannot have method bodies.
2) An abstract class cannot be instantiated.
3) An abstract class must have at least one abstract method.
4) None of the above
Answer : An abstract class cannot be instantiated.
Which of the following is the parent class of all classes in Java?
1) Object
2) Class
3) Super
4) None of the above
Answer : Object
What is the use of the "super" keyword in Java?
1) To refer to the current class
2) To refer to the parent class
3) To call a method from the same class
4) None of the above
Answer : To refer to the parent class