Learn JAVA MCQs

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

Which of the following is true about multiple inheritance in Java?

1) It is not supported through classes.

2) It is supported through interfaces.

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following is a method of the Math class in Java?

1) sqrt()

2) max()

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following is true about method overloading in Java?

1) The methods must have the same name.

2) The methods must have different parameter lists.

3) The methods must have different return types.

4) None of the above

Answer : The methods must have different parameter lists.

Which of the following is true about an abstract method in Java?

1) It has a body.

2) It has no body.

3) It must be private.

4) None of the above

Answer : It has no body.

What is the output of System.out.println(10 & 2);?

1) 0

2) 2

3) 10

4) None of the above

Answer : 2

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

1) final

2) const

3) static

4) None of the above

Answer : final

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

1) true

2) false

3) 1

4) None of the above

Answer : true

Which of the following is used to print output in Java?

1) System.out.println()

2) print()

3) cout

4) None of the above

Answer : System.out.println()

Which of the following is true about static methods in Java?

1) They belong to the class rather than the instance.

2) They can only access static data.

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following is true about an abstract class in Java?

1) It cannot be instantiated.

2) It can have abstract and non-abstract methods.

3) It is declared using the abstract keyword.

4) All of the above

Answer : All of the above