Learn JAVA MCQs

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

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

1) 523

2) 10

3) Error

4) None of the above

Answer : 523

Which of the following is used to read data from a file in Java?

1) FileReader

2) FileWriter

3) BufferedReader

4) All of the above

Answer : All of the above

What is the output of System.out.println(9 ^ 3);?

1) 10

2) 8

3) 9

4) None of the above

Answer : 10

Which of the following is used to create a new instance of a class?

1) new

2) create

3) instantiate

4) None of the above

Answer : new

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 characteristic of a constructor in Java?

1) It has the same name as the class.

2) It can return a value.

3) It can be private.

4) All of the above

Answer : All of the above

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

1) 0

2) 1

3) Error

4) None of the above

Answer : Option 1

Which of the following is true about `LinkedList` in Java?

1) It is faster than ArrayList for insertions.

2) It supports dynamic arrays.

3) It is synchronized.

4) None of the above

Answer : It is faster than ArrayList for insertions.

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

1) 3

2) 3.0

3) 3.33

4) None of the above

Answer : 3

Which of the following is not a feature of Java?

1) Platform independence

2) Object-oriented

3) Use of pointers

4) Multithreading

Answer : Use of pointers