Learn JAVA MCQs

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

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

1) break

2) exit

3) return

4) None of the above

Answer : break

What is the output of System.out.println(true && false);?

1) true

2) false

3) 1

4) None of the above

Answer : false

Which of the following is not a valid operator in Java?

1) &&

2) ||

3) ^^

4) None of the above

Answer : ^^

What is the default value of a boolean in Java?

1) true

2) false

3) null

4) undefined

Answer : false

Which of the following is not a valid data type in Java?

1) int

2) float

3) double

4) bytecode

Answer : bytecode

What does JVM stand for?

1) Java Variable Machine

2) Java Virtual Machine

3) Java Version Manager

4) Java Verified Machine

Answer : Java Virtual Machine

Which of the following is used to read input from the user in Java?

1) Scanner class

2) BufferedReader class

3) InputStreamReader class

4) None of the above

Answer : Scanner class

Which of the following is true about final variables in Java?

1) They can be modified after initialization.

2) They cannot be modified once initialized.

3) They are only accessible within the method they are declared.

4) None of the above

Answer : They cannot be modified once initialized.

Which of the following is used to find the length of an array in Java?

1) length()

2) size()

3) length

4) None of the above

Answer : length

Which of the following is true about interfaces in Java?

1) An interface can extend another interface.

2) An interface can implement another interface.

3) An interface can have a constructor.

4) None of the above

Answer : An interface can extend another interface.