Learn JAVA MCQs

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

What will be the output of System.out.println(4 == 5);?

1) true

2) false

3) 1

4) 0

Answer : false

Which of the following is not a Java access modifier?

1) public

2) private

3) protected

4) internal

Answer : internal

Which of the following is the correct syntax for defining an array in Java?

1) int[] arr;

2) int arr[];

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following statements is true about the final keyword in Java?

1) final variables cannot be changed.

2) final methods cannot be overridden.

3) final classes cannot be inherited.

4) All of the above

Answer : All of the above

What is the output of System.out.println(10 % 3);?

1) 1

2) 2

3) 3

4) None of the above

Answer : 1

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 the superclass of all classes in Java?

1) String

2) Object

3) Class

4) None of the above

Answer : Object

Which method is used to find the length of a string in Java?

1) size()

2) length()

3) length[]

4) None of the above

Answer : length()

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

1) 14

2) 11

3) 10

4) None of the above

Answer : 11

Which of the following methods can be overridden in Java?

1) final method

2) static method

3) instance method

4) None of the above

Answer : instance method