Learn JAVA MCQs

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

Which of the following is not a Java reserved keyword?

1) static

2) package

3) native

4) constructor

Answer : constructor

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

1) World

2) Hello

3) Hello World

4) None of the above

Answer : World

Which of the following is not a feature of exception handling in Java?

1) Catching exceptions

2) Throwing exceptions

3) Ignoring exceptions

4) Propagating exceptions

Answer : Ignoring exceptions

Which of the following is used to check equality between objects in Java?

1) ==

2) equals()

3) Both 1 and 2

4) None of the above

Answer : equals()

What is the output of System.out.println(Math.sqrt(16));?

1) 2

2) 3

3) 4

4) None of the above

Answer : 4

What is the output of System.out.println("Java".startsWith("J"));?

1) true

2) false

3) Error

4) None of the above

Answer : true

Which of the following is a valid method of the String class in Java?

1) equals()

2) substring()

3) replace()

4) All of the above

Answer : All of the above

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

1) 333

2) 63

3) 36

4) Error

Answer : 333

Which of the following is the correct way to create an array in Java?

1) int[] arr = new int[5];

2) int arr[] = new int[5];

3) Both 1 and 2

4) None of the above

Answer : Both 1 and 2

Which of the following methods is used to stop a thread in Java?

1) stop()

2) sleep()

3) terminate()

4) None of the above

Answer : stop()