Learn JAVA MCQs

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

What is the output of System.out.println(5 < 6 && 6 > 5);?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is used to declare 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

What is the output of System.out.println("5" + 5);?

1) 55

2) 10

3) Error

4) None of the above

Answer : 55

Which of the following is a built-in exception in Java?

1) IOException

2) FileNotFoundException

3) NullPointerException

4) All of the above

Answer : All of the above

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

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is not an interface in Java?

1) Runnable

2) Serializable

3) FileReader

4) Cloneable

Answer : FileReader

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

1) true

2) false

3) Error

4) None of the above

Answer : false

Which of the following is a valid declaration of a method in Java?

1) public void methodName() {}

2) void methodName() {}

3) public methodName() {}

4) None of the above

Answer : public void methodName() {}

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

1) hello

2) Hello

3) HELLO

4) None of the above

Answer : hello

Which of the following can be used to implement multiple inheritance in Java?

1) Interfaces

2) Abstract classes

3) Both 1 and 2

4) None of the above

Answer : Interfaces