Learn JAVA MCQs

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

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

1) va

2) Java

3) Ja

4) None of the above

Answer : va

Which of the following is used to terminate a program in Java?

1) System.exit()

2) return

3) break

4) None of the above

Answer : System.exit()

What is the output of System.out.println(15 ^ 5);?

1) 10

2) 5

3) 20

4) None of the above

Answer : 10

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

1) List

2) Set

3) Array

4) Queue

Answer : Array

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

1) Hello World

2) HelloWorld

3) Hello

4) None of the above

Answer : Hello World

Which of the following is true about an interface in Java?

1) It can contain abstract methods.

2) It can contain concrete methods.

3) It can contain instance variables.

4) None of the above

Answer : It can contain abstract methods.

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

1) 3

2) 2

3) 4

4) None of the above

Answer : 3

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

1) true

2) false

3) Error

4) None of the above

Answer : true

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

1) char c = u0055;

2) char c = "U";

3) char c = 65;

4) char c = 1;

Answer : char c = u0055;

Which of the following is a marker interface?

1) Serializable

2) Runnable

3) Cloneable

4) Both 1 and 3

Answer : Both 1 and 3