Learn JAVA MCQs

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

Which of the following is a feature of the final keyword in Java?

1) A final class can be inherited.

2) A final method can be overridden.

3) A final variable can be modified.

4) None of the above

Answer : None of the above

Which of the following is a checked exception in Java?

1) NullPointerException

2) ArithmeticException

3) FileNotFoundException

4) None of the above

Answer : FileNotFoundException

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

1) 3

2) 3.33

3) 3.0

4) None of the above

Answer : 3

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

1) Single inheritance

2) Multiple inheritance

3) Hybrid inheritance

4) None of the above

Answer : Single inheritance

Which of the following is not a valid keyword in Java?

1) goto

2) volatile

3) const

4) None of the above

Answer : const

What is the output of System.out.println("Hello".length());?

1) 5

2) 6

3) 4

4) None of the above

Answer : 5

Which of the following is true about a try-catch block in Java?

1) A try block must be followed by a catch block.

2) A try block can be followed by multiple catch blocks.

3) A catch block can exist without a try block.

4) None of the above

Answer : A try block can be followed by multiple catch blocks.

Which of the following is true about interfaces in Java?

1) An interface can extend multiple interfaces.

2) An interface can implement multiple interfaces.

3) An interface can extend a class.

4) None of the above

Answer : An interface can extend multiple interfaces.

Which of the following is a correct way to declare a constant in Java?

1) int x = 10;

2) final int x = 10;

3) const int x = 10;

4) None of the above

Answer : final int x = 10;

What is the output of System.out.println(10 * 2 / 5);?

1) 2

2) 4

3) 5

4) None of the above

Answer : 4