Java MCQs

Naveen AnamaneniUpdated · 8 min read

Before a board exam, most students do a stack of objective questions: they are quick, they cover a lot of ground, and every wrong answer points straight at a gap. Java placement tests and online assessments work the same way, usually opening with a round of multiple choice questions (MCQs). This page collects MCQs on every major part of core Java, grouped by topic. Each quiz marks your answers and explains every question, so you learn from the mistakes as well as the score.

How to Use These Quizzes

  • Do one topic at a time, without looking anything up.
  • Aim for 4 out of 5 or better on each quiz. Below that, reread the lessons for that topic.
  • For every question you got right by guessing, read the explanation anyway.
  • Come back a week later and try again. Spaced repetition is what makes it stick.

Java Basics

MCQ: Java basics

5 questions
1What is the default value of an int field?
2Which of these is not a primitive type?
3What is the size of a char in Java?
4What does the JVM execute?
5Which keyword stops a loop immediately?

Object-Oriented Programming

MCQ: OOP

5 questions
1Which OOP principle hides data behind methods?
2Can a class extend two classes in Java?
3Which is decided at runtime?
4What does super() do in a constructor?
5Which members does an interface allow since Java 9?

Strings

MCQ: Strings

5 questions
1Why is String immutable?
2Which is fastest for building a string in a loop on one thread?
3What does "Java".substring(1, 3) return?
4How should two strings be compared for equal text?
5What does " Navika ".strip() return?

Exceptions

MCQ: Exceptions

5 questions
1Which is a checked exception?
2When does a finally block run?
3What is the parent of all exceptions and errors?
4What does try-with-resources need from a resource?
5Which keyword declares that a method may throw a checked exception?

Collections

MCQ: Collections

5 questions
1Which collection keeps no duplicates?
2Which map keeps keys sorted?
3What is the average cost of HashMap.get?
4What happens if you modify an ArrayList while looping over it with for-each?
5Which is the best general-purpose stack in modern Java?

Multithreading

MCQ: Multithreading

5 questions
1Which method starts a new thread?
2What does synchronized guarantee?
3What does volatile guarantee?
4Which class gives a thread-safe counter without locks?
5What do virtual threads (Java 21) make cheap?

Java 8 and Modern Java

MCQ: Java 8 and modern Java

5 questions
1What is a functional interface?
2Which stream operation is terminal?
3What does Optional.orElse("none") return for an empty Optional?
4Which feature lets you write record Point(int x, int y) {}?
5What does var do?

Practice

  1. Easy: Take all seven quizzes in one sitting and record your score for each. Which topic was weakest?
  2. Harder: For your weakest topic, write five new MCQs of your own, each with one correct answer, three believable wrong ones and a one-line explanation. Writing good wrong options is the best way to learn a topic.

Key Takeaways

Was this tutorial helpful?

Lesson 568 of 578