Learn JAVA MCQs

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

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

1) 16

2) 8

3) 4

4) None of the above

Answer : 16

Which of the following is a wrapper class in Java?

1) int

2) boolean

3) Integer

4) None of the above

Answer : Integer

What is the output of System.out.println("Java".contains("ava"));?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is true about `ArrayList`?

1) It can store duplicate elements.

2) It maintains insertion order.

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

What is the output of System.out.println("abc".toUpperCase());?

1) ABC

2) abc

3) Abc

4) None of the above

Answer : ABC

Which of the following is not a part of the Java Collection Framework?

1) List

2) Set

3) Map

4) Array

Answer : Array

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 can be used to create a new thread?

1) Thread class

2) Runnable interface

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

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

1) 3

2) 2

3) 1

4) None of the above

Answer : 3

Which of the following is a primitive type in Java?

1) String

2) Integer

3) boolean

4) None of the above

Answer : boolean