Learn JAVA MCQs

Prepare JAVA MCQs (Multiple choice Questions) for exam and job interviews.

Which keyword is used to define a method that cannot be overridden in Java?

1) static

2) final

3) abstract

4) None of the above

Answer : final

Which of the following is a primitive data type in Java?

1) Integer

2) int

3) String

4) None of the above

Answer : int

What is the output of System.out.println(2 * 3 + 4);?

1) 10

2) 14

3) 6

4) None of the above

Answer : 10

Which of the following is a valid syntax for an enhanced for loop in Java?

1) for (int i : arr)

2) for (i : arr)

3) for (arr : i)

4) None of the above

Answer : for (int i : arr)

Which of the following is a type of polymorphism in Java?

1) Method overloading

2) Method overriding

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following statements is true about constructors in Java?

1) Constructors can be overloaded.

2) Constructors can be inherited.

3) Constructors cannot have parameters.

4) None of the above

Answer : Constructors can be overloaded.

Which method is used to terminate a thread in Java?

1) terminate()

2) stop()

3) kill()

4) None of the above

Answer : stop()

What is the output of System.out.println(1 + 2 + "3");?

1) 123

2) 33

3) 6

4) None of the above

Answer : 33

Which of the following is not an access modifier in Java?

1) private

2) protected

3) public

4) final

Answer : final

Which keyword is used to define an abstract method in Java?

1) static

2) final

3) abstract

4) None of the above

Answer : abstract