Java Quizzes
Test your Java skills with our quiz questions. Practice writing code for classes, objects, and common Java features. These quizzes help your understanding of Java basics and will prepare you for building real applications and passing coding tests.
About Java Quiz
Each Java quiz consists of multiple questions, each with three to four possible answers. Only one answer is correct for each question. Select the answer you believe is correct, then click the "Check My Answers" button to see your results.
If you answer at least 75% of the questions correctly, you pass the quiz! This indicates you have a solid understanding of Java concepts and are ready to advance to more challenging topics.
After submitting your quiz, you'll receive immediate feedback with detailed explanations for each question. This helps you understand not just what the correct answer is, but why it's correct—reinforcing your learning and helping you master Java.
Quick Tips
- Read each question carefully before selecting your answer
- Review the code examples when provided
- You can retake quizzes as many times as you want
- Sign in to save your progress and track your performance
Available Quizzes
Java Basics & JVM Fundamentals
50 in-depth questions (30 with code) covering Java platform independence, JVM architecture, compilation, bytecode, class loading, memory areas, garbage collection, and your first real Java program.
Variables, Data Types & Type Casting
40 focused questions Java primitive and reference types, variable declaration rules, widening/narrowing conversions, the final keyword, and the most common type-casting pitfalls.
Operators & Expressions
40 medium-to-advanced questions Java operators & expressions that force deep thinking about arithmetic, relational, logical, assignment, and ternary operators — including precedence traps, short-circuit behavior, compound assignment quirks, and real-world expression bugs.
Strings & String Methods
35 in-depth questions covering String immutability, object creation, comparison behavior, common methods, StringBuilder/StringBuffer usage, and performance implications in real-world Java code.
Numbers & Math Class
35 deep-dive questions on Java's numerical capabilities, from Math utilities and rounding behavior to BigInteger/BigDecimal precision, number formatting, and the subtle dangers of primitive overflow.
Arrays & Multi-Dimensional Arrays
35 deep and practical questions on Java arrays — from declaration and initialization to advanced 2D/3D usage, Arrays utility methods, common pitfalls, and performance gotchas that trip even senior developers.
Classes, Objects & Constructors
40 deep and challenging questions that explore every corner of object creation, constructor behavior, the true meaning of this, the subtle differences between instance and static members, and the complete lifecycle of objects in Java.
Methods, Parameters & Overloading
35 challenging and insight-revealing questions that dive deep into how Java really handles method invocation, parameter passing, overloading resolution, varargs behavior, return type rules, and the subtle edge cases that surprise even experienced developers.
Packages & Import Statements
40 deep, practical, and often overlooked questions about Java packages — from directory structure enforcement and classpath mechanics to import rules, static imports, naming conventions, and the subtle ways packages affect accessibility, compilation, and runtime behavior.
Control Flow (if, else, switch)
35 deep, real-world, and frequently misunderstood questions about Java control flow — covering if-else pitfalls, dangling else, fall-through dangers, modern switch expressions, pattern matching, exhaustive checking, and the best practices that prevent bugs in production code.
Loops (for, while, do-while)
35 deep, practical, and often misunderstood questions about Java loops — from subtle break/continue label behavior and enhanced for-loop limitations to infinite loop detection, do-while quirks, loop unrolling myths, and the performance & safety best practices used in real production systems.
Encapsulation & Abstraction in OOP
35 in-depth questions (15 with code) covering encapsulation principles, getters/setters implementation, abstraction concepts, abstracting behavior, and design benefits in object-oriented programming.
Polymorphism (Compile-Time & Runtime)
35 in-depth questions (15 with code) covering method overloading as compile-time polymorphism, overriding as runtime polymorphism, dynamic method dispatch, upcasting/downcasting, and why polymorphism matters in object-oriented design.
Interfaces, Abstract Classes & Multiple Inheritance
35 in-depth questions (15 with code) covering interface basics, abstract class fundamentals, default/static methods in interfaces, functional interfaces, and multiple inheritance resolution in Java.
Exception Handling (try, catch, finally)
40 in-depth questions (20 with code) covering types of exceptions, try/catch syntax, finally block purpose, stack traces, and best practices in Java exception handling.
Custom Exceptions & Exception Hierarchy
30 in-depth questions (15 with code) covering creating custom exceptions, throw vs throws, checked vs unchecked exceptions, chained exceptions, and designing exception structures in Java.
Collections Framework (List, Set, Map)
35 in-depth questions (18 with code) covering List types (ArrayList, LinkedList), Set types (HashSet, TreeSet), Map types (HashMap, TreeMap), Collections utility class, and choosing the right collection for different use cases in Java.
Generics Deep Dive
35 in-depth questions (18 with code) covering why generics exist, generic methods, bounded type parameters, wildcards (? extends, ? super), and raw types pitfalls in Java.
Java I/O (Files, Streams, Readers/Writers)
35 in-depth questions (18 with code) covering Input/Output streams, Readers vs Writers, File operations, Buffered I/O, and handling I/O exceptions in Java.
Date & Time API (java.time)
35 in-depth questions (18 with code) covering LocalDate & LocalTime, LocalDateTime & ZonedDateTime, formatting dates, parsing dates, and Duration & Period in Java's modern date-time API.
Streams API (map, filter, reduce)
Master the Java Streams API for functional-style operations on collections. Learn to create streams, use intermediate operations like map and filter, apply terminal operations, perform reductions, and follow best practices for efficient stream processing.
JVM Memory Model (Heap, Stack, GC)
Understand the JVM memory architecture including heap and stack management, garbage collection mechanisms, classloader hierarchy, memory leak prevention, and JVM optimization techniques.
