Learn JAVA MCQs

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

What is the output of System.out.println(8 & 5);?

1) 0

2) 1

3) 4

4) None of the above

Answer : Option 1

Which of the following is the correct way to create a thread in Java?

1) new Thread()

2) new Runnable()

3) Both 1 and 2

4) None of the above

Answer : new Thread()

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

1) 55

2) 5

3) 10

4) None of the above

Answer : 55

What is the default value of a reference type variable in Java?

1) null

2) 0

3) false

4) None of the above

Answer : null

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

1) It cannot have concrete methods.

2) It can have constructors.

3) It cannot be instantiated.

4) Both 2 and 3

Answer : Both 2 and 3

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

1) 532

2) 10

3) Error

4) None of the above

Answer : 532

Which of the following is a non-primitive data type in Java?

1) int

2) char

3) String

4) float

Answer : String

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

1) 78

2) 10

3) Error

4) None of the above

Answer : 78

What is the purpose of the `break` statement in Java?

1) To exit a loop

2) To exit a method

3) To terminate the program

4) None of the above

Answer : To exit a loop

What is the output of System.out.println("Java".substring(1, 3));?

1) Ja

2) av

3) va

4) None of the above

Answer : av