ā˜• Java

Java MCQ — 100 Multiple Choice Questions

A complete set of 100 Java MCQ with correct answers and detailed explanations for Fresher, Mid-Level, and Senior developers — covering Java basics, OOP, Strings, Arrays, Collections, Exception Handling, Java 8+ features, Multithreading, and JVM internals.

šŸ“…

Last Updated

March 2026

ā“

Questions

100 MCQ

šŸŽÆ

Level

Fresher + Mid + Senior

How to Use This MCQ Guide

This guide contains 100 Java MCQ questions with detailed explanations organized by topic and difficulty. Each question is designed to test not just recall but real conceptual understanding — exactly what is tested in placement exams, coding rounds, and technical interviews.

SectionQuestionsLevelTopics
Java BasicsQ1–Q20🟢 FresherData types, keywords, operators, control flow, OOP basics
OOP ConceptsQ21–Q35🟢 FresherInheritance, polymorphism, abstraction, interfaces, encapsulation
Strings & ArraysQ36–Q48🟔 MidString methods, immutability, array operations, sorting
CollectionsQ49–Q63🟔 MidList, Map, Set, Queue internals and behavior
Exception HandlingQ64–Q73🟔 Midtry-catch-finally, checked vs unchecked, throw vs throws
Java 8+ FeaturesQ74–Q84🟔 MidLambda, Streams, Optional, functional interfaces, Records
MultithreadingQ85–Q93šŸ”“ SeniorThread lifecycle, synchronization, volatile, deadlock
JVM & AdvancedQ94–Q100šŸ”“ SeniorMemory areas, GC, ClassLoader, JIT, modern Java features

Strategy: Attempt the answer before reading the explanation. Active recall doubles retention compared to passive reading. Time yourself — aim for under 45 seconds per question in a real exam.

Java Basics MCQ (Q1–Q20)

These 20 questions test core Java fundamentals — data types, operators, keywords, control flow, and basic syntax. These appear in all campus placement tests, online assessments, and fresher-level technical rounds.

Q1. Which of the following is NOT a primitive data type in Java?

Must Know

Q2. What is the output of: System.out.println(10 + 20 + "Java");

Must Know

Q3. What is the default value of a boolean instance variable in Java?

Must Know

Q4. Which keyword is used to prevent a class from being subclassed in Java?

Must Know

Q5. What is the size of an int in Java regardless of the platform?

Must Know

Q6. Which of the following correctly declares a multi-dimensional array in Java?

Frequently Asked

Q7. What is the output of: System.out.println(5 / 2);

Must Know

Q8. Which of the following is used to find the length of an array named 'arr' in Java?

Must Know

Q9. What does the 'static' keyword mean when applied to a method?

Must Know

Q10. What is the output of: int x = 5; System.out.println(x++);

Must Know

Q11. Which access modifier makes a member accessible only within the same class?

Must Know

Q12. What is the output of: System.out.println(2 + 3 * 4);

Frequently Asked

Q13. Which of the following is a valid way to create an object of class 'Car' in Java?

Must Know

Q14. What is the purpose of the 'this' keyword in Java?

Must Know

Q15. Which loop in Java is guaranteed to execute its body at least once?

Must Know

Q16. What is the result of: System.out.println("Java".charAt(2));

Frequently Asked

Q17. Which of the following is NOT a Java keyword?

Frequently Asked

Q18. What happens when you try to divide an integer by zero in Java?

Must Know

Q19. Which keyword is used to jump to the next iteration of a loop in Java?

Must Know

Q20. What is the output of: System.out.println(true && false || true);

Must Know

OOP Concepts MCQ (Q21–Q35)

OOP is the most heavily tested topic in Java interviews at all levels. These 15 questions cover the four pillars, inheritance, polymorphism, interfaces, and encapsulation.

Q21. Which OOP concept allows one class to inherit the properties of another?

Must Know

Q22. What is the output when a child class overrides a parent method and calls super.method()?

Must Know

Q23. Which of the following cannot be overridden in Java?

Must Know

Q24. What is method overloading?

Must Know

Q25. What is an abstract class in Java?

Must Know

Q26. Which interface method modifier was introduced in Java 8 to provide a default implementation?

Must Know

Q27. What is the correct way to implement an interface in Java?

Must Know

Q28. What is encapsulation in Java?

Must Know

Q29. Can a constructor be declared as static in Java?

Frequently Asked

Q30. What is the output? class A { void show() { System.out.print('A'); } } class B extends A { void show() { System.out.print('B'); } } A obj = new B(); obj.show();

Must Know

Q31. Which of the following statements about interfaces in Java is TRUE?

Must Know

Q32. What does the 'super' keyword refer to in Java?

Must Know

Q33. What is the difference between IS-A and HAS-A relationships in Java?

Frequently Asked

Q34. In Java, which of the following access modifiers provides the broadest visibility?

Must Know

Q35. What is a marker interface in Java?

Frequently Asked

Strings & Arrays MCQ (Q36–Q48)

String and array questions are among the most common in placement tests. These 13 questions test immutability, string pool, key methods, and array operations.

Q36. Which of the following correctly compares two String values in Java?

Must Know

Q37. What is the output of: String s1 = "Java"; String s2 = "Java"; System.out.println(s1 == s2);

Must Know

Q38. Which class should you use for efficient string concatenation in a loop?

Must Know

Q39. What does String.substring(2, 5) return for the string "JavaProgramming"?

Frequently Asked

Q40. What is the output of: System.out.println("Hello".replace('l', 'r'));

Frequently Asked

Q41. Which method splits a String "a,b,c" into an array ["a","b","c"]?

Frequently Asked

Q42. What is the output of: System.out.println(" Java ".trim());

Must Know

Q43. What does Arrays.sort(arr) use internally for primitive arrays in Java?

Frequently Asked

Q44. What is the output of: int[] arr = {1,2,3}; System.out.println(arr);

Must Know

Q45. What is the output of: String s = "Java"; s.concat(" World"); System.out.println(s);

Must Know

Q46. How do you copy an array in Java to create an independent duplicate?

Frequently Asked

Q47. What will String.valueOf(null) return in Java?

Frequently Asked

Q48. What is the time complexity of searching an element in an unsorted array?

Frequently Asked

Collections Framework MCQ (Q49–Q63)

Collections are asked in virtually every Java interview. These 15 questions cover List, Map, Set, Queue internals, thread safety, and iteration patterns.

Q49. Which Collection allows duplicate elements and maintains insertion order?

Must Know

Q50. What does HashMap.get(key) return when the key does not exist?

Must Know

Q51. Which Map implementation maintains keys in sorted order?

Must Know

Q52. What happens when you try to add a duplicate element to a HashSet?

Must Know

Q53. Which interface does LinkedList implement that ArrayList does NOT?

Must Know

Q54. What is the default initial capacity of ArrayList in Java?

Frequently Asked

Q55. Which of the following is thread-safe?

Must Know

Q56. What does the PriorityQueue in Java use to determine element ordering?

Frequently Asked

Q57. Which method would you use to iterate over a Map's key-value pairs?

Must Know

Q58. What exception does Collections.unmodifiableList() throw when you try to modify it?

Frequently Asked

Q59. Which data structure does HashSet use internally?

Frequently Asked

Q60. What is the output? List<String> list = Arrays.asList("A","B","C"); list.add("D");

Must Know

Q61. What is the difference between Iterator.remove() and Collection.remove()?

Must Know

Q62. Which implementation of BlockingQueue should be used for a bounded producer-consumer queue?

Frequently Asked

Q63. What is the correct way to sort a List of Strings in reverse alphabetical order in Java 8?

Must Know

Exception Handling MCQ (Q64–Q73)

Exception handling questions test your understanding of Java's compile-time safety, runtime behavior, and resource management. These 10 questions cover all key concepts.

Q64. Which of the following is a checked exception in Java?

Must Know

Q65. What is the output? try { System.out.print("A"); } finally { System.out.print("B"); } System.out.print("C");

Must Know

Q66. Which keyword is used to manually throw an exception in Java?

Must Know

Q67. In which order are multiple catch blocks evaluated?

Must Know

Q68. What does the finally block execute in the following? try { return 1; } finally { return 2; }

Must Know

Q69. What is try-with-resources in Java?

Must Know

Q70. Which of the following exceptions is thrown when you access an invalid array index?

Frequently Asked

Q71. What is the relationship between Exception and Error in Java?

Must Know

Q72. What happens when a checked exception is not handled or declared with throws?

Must Know

Q73. What is multi-catch in Java 7+?

Frequently Asked

Java 8+ Features MCQ (Q74–Q84)

Java 8 features are asked in almost every mid-level Java interview. These 11 questions cover Lambda, Streams, Optional, functional interfaces, method references, and Records.

Q74. What is a functional interface in Java?

Must Know

Q75. What is the output? List.of(1,2,3,4,5).stream().filter(n -> n % 2 == 0).map(n -> n * n).collect(Collectors.toList());

Must Know

Q76. Which method of Optional returns the value if present, or throws NoSuchElementException if empty?

Must Know

Q77. What is the difference between map() and flatMap() in Java Streams?

Must Know

Q78. What is the output? Optional.of("Java").map(String::toUpperCase).orElse("Empty");

Frequently Asked

Q79. Which collector is used to group Stream elements by a key in Java 8?

Must Know

Q80. What does 'effectively final' mean in the context of lambda expressions?

Must Know

Q81. What is a Record in Java 16+?

Must Know

Q82. What is the output of: Stream.of(1,2,3).reduce(0, (a,b) -> a + b);

Frequently Asked

Q83. Which statement about method references is TRUE?

Must Know

Q84. What is Collectors.joining() used for in Java Streams?

Frequently Asked

Multithreading MCQ (Q85–Q93)

Multithreading questions separate mid-level from senior candidates. These 9 questions cover thread lifecycle, synchronization, volatile, deadlock, and modern concurrency.

Q85. Which method is used to start a thread in Java?

Must Know

Q86. What is the difference between synchronized method and synchronized block?

Must Know

Q87. What does volatile guarantee in Java?

Must Know

Q88. Which class provides atomic operations on integers without using synchronized?

Must Know

Q89. What is a deadlock in Java?

Must Know

Q90. What is the purpose of the wait() and notify() methods?

Must Know

Q91. Which of the following is TRUE about ConcurrentHashMap?

Must Know

Q92. What is ThreadLocal in Java?

Frequently Asked

Q93. What are Virtual Threads in Java 21?

Must Know

JVM & Advanced Java MCQ (Q94–Q100)

These 7 questions cover JVM internals, Garbage Collection, ClassLoader, JIT, and modern Java features — expected from senior candidates.

Q94. Where are Java objects stored in memory?

Must Know

Q95. What does the Garbage Collector do in Java?

Must Know

Q96. What is the difference between PermGen and Metaspace?

Must Know

Q97. Which ClassLoader loads the core Java classes (java.lang, java.util)?

Frequently Asked

Q98. What is the JIT compiler in Java?

Frequently Asked

Q99. What is a sealed class in Java 17?

Must Know

Q100. What is the output of: var list = new ArrayList<>(); list.add("Java"); list.add(21); System.out.println(list);

Must Know

Score Interpretation Guide

Use this guide to evaluate your MCQ performance and plan your next steps accordingly.

ScoreInterpretationRecommended Action
90–100 / 100šŸ† Excellent — Senior ReadyYou have mastery of Java. Focus on system design, architecture discussions, and LeetCode hard problems.
75–89 / 100āœ… Good — Mid-Level ReadyStrong core knowledge. Revisit weak sections (note which Q numbers you missed). Practice coding rounds.
60–74 / 100🟔 Intermediate — Needs ReinforcementGood foundation but gaps exist. Re-read explanations for missed questions. Build small projects to reinforce concepts.
45–59 / 100🟠 Developing — Fresher ReadyCore concepts understood but mid-level gaps. Focus on Collections internals, Exception Handling, and Java 8 features.
Below 45 / 100šŸ”“ Beginner — Foundation NeededStart with Java basics. Complete the full Java tutorial series. Revisit Q1–Q35 thoroughly before attempting mid-level material.
  • ā–¶

    šŸ“Œ Track your weak sections — Note which sections had the most mistakes. Collections and Multithreading are the most commonly weak areas for mid-level candidates.

  • ā–¶

    šŸ“Œ Retake after 3 days — Spaced repetition is proven to improve retention. Retake the MCQ set after 3 days without looking at answers first.

  • ā–¶

    šŸ“Œ Explain answers aloud — If you can explain WHY an answer is correct to someone else, you truly understand it. This is the most effective preparation technique for technical interviews.

  • ā–¶

    šŸ“Œ Pair with Interview Questions — After each MCQ section, read the corresponding section in the Java Interview Questions guide for deeper explanations and related open-ended Q&A.

Conclusion — From MCQ Confidence to Interview Success

You have now practiced 100 Java MCQ questions covering every major topic from basic syntax to JVM internals. MCQ practice builds the pattern recognition needed to answer quickly and confidently in timed assessments — but the real goal is deep understanding, not just memorizing correct options.

MCQ SectionQuestionsKey Concepts to Reinforce
Java BasicsQ1–Q20Primitive types, operators, default values, control flow, static keyword
OOP ConceptsQ21–Q35Four pillars, overloading vs overriding, abstract vs interface, super/this
Strings & ArraysQ36–Q48Immutability, String pool, StringBuilder, substring indexing, array sort
CollectionsQ49–Q63HashMap internals, fail-fast vs fail-safe, Comparable vs Comparator, thread safety
Exception HandlingQ64–Q73Checked vs unchecked, finally execution, try-with-resources, multi-catch
Java 8+ FeaturesQ74–Q84Functional interfaces, Stream pipeline, Optional, method references, Records
MultithreadingQ85–Q93start() vs run(), volatile, AtomicInteger, deadlock, ConcurrentHashMap, ThreadLocal
JVM & AdvancedQ94–Q100Heap vs Stack, GC, PermGen vs Metaspace, JIT, ClassLoader, sealed classes
  • ā–¶

    āœ… Next step for Freshers — Build 3 small Java projects using OOP, Collections, and Exception Handling. Portfolio > certificates.

  • ā–¶

    āœ… Next step for Mid-level — Study the Java Interview Questions guide for open-ended answers. Practice explaining concepts verbally.

  • ā–¶

    āœ… Next step for Senior — Practice system design (design a URL shortener, a cache, a rate limiter using Java data structures). Study Effective Java by Josh Bloch.

  • ā–¶

    šŸ’” Final tip — The best Java developers don't just know APIs — they understand the WHY behind every design decision. When you understand WHY HashMap uses power-of-two capacity, WHY Strings are immutable, and WHY volatile doesn't guarantee atomicity, you stop memorizing and start thinking like a Java architect. ā˜•

Frequently Asked Questions (FAQ)