Free Java Online Test and Interview Questions
Check your Java Core knowledge in two ways: take a timed test and get a score, or work through interview questions with answers at your own pace. Pick the topics, choose 5 to 100 questions — no registration needed.
Java online test
Multiple-choice questions on the topics you select. At the end you see your result as a percentage, every question, your answer and the correct one.
Java interview questions with answers
Typical interview questions by topic. Read a question, answer it in your head, then reveal the answer — a fast way to revise a module before an interview or an exam.
How it works
- Choose topics. Select one lesson, a whole module or several modules of the Java Core course.
- Set the length. From 5 to 100 questions; a typical test takes 10–30 minutes.
- Test questions are practical. Many show a code fragment: decide whether it compiles, what it prints, find the error or fill in the missing part.
- Review the result. After the test you get a score and a full review with the correct answers. Interview questions show the answer right away.
What the tests and questions cover
1618 test questions and 1332 interview questions across 30 modules. Open a module to see its lessons; a lesson link opens its interview questions.
What Is Java? Introduction to Java Programming
How to Create and Run Your First Java Application
- How to Write Your First Java Application
- Compile and Run Java Applications from the Command Line – Step-by-Step
- Understanding Java Packages: A Comprehensive Guide with Examples
- Java Compilation: -sourcepath and -classpath Explained
- How to Create and Use JAR Files in Java
- Command-Line Arguments in Java: How to Use Them
Java Syntax Basics: Variables, Identifiers, and Structure
- Java Language Lexicon: Whitespace, Identifiers, Keywords & Comments
- Best Practices for Naming Java Identifiers: Classes, Methods, Constants & Packages
- Primitive Types and Literals in Java
- Java Methods: Syntax, Parameters, Return Types, and Best Practices
- Java Variables: Declaration, Initialization and Scope
- Sign-Magnitude, One's Complement and Two's Complement
- Primitive Type Conversion in Java: Implicit and Explicit Type Casting
- Java User Input: Reading Data from Keyboard with System.in and Scanner
Basic Operations in Java: Arithmetic and Logical
- Learn Java Arithmetic Operators and Compound Assignment with Examples
- Understanding Java Increment and Decrement Operators
- Understanding Java Comparison Operators: Equal, Greater, Less and More
- Logical Operators in Java
- Ternary Operator in Java – How It Works and When to Use It
- The Assignment Operator (=) in Java
- Java Operator Precedence Table and Examples
- Java String Concatenation: Rules, Examples, and Unicode Encoding
- Bitwise and Bit Shift Operators in Java
Conditional Statements and Loops in Java (if, switch, for, while)
Arrays in Java: How to Create and Use Them
Object-Oriented Programming in Java (OOP Concepts)
- Procedural vs Object-Oriented Programming
- Object-Oriented Programming (OOP) Concepts in Java
- Classes and Objects in Java
- Java Constructor Types: Default and Parameterized
- The this Keyword in Java
- Method and Constructor Overloading in Java
- Java Memory Structure: Stack and Heap
- Passing Objects to Methods in Java
- Java Varargs: Methods with Variable-Length Arguments
- Recursion in Java Explained
- Garbage Collection
- Java Inheritance and the extends Keyword
- The super Keyword in Java
- Access Modifiers in Java
- JavaBeans Naming Conventions: Getters, Setters and boolean is
- Method Overloading vs Overriding in Java
- Abstract Classes and Methods in Java
- The final Keyword in Java
- The native Keyword in Java
The static Keyword in Java: Variables, Methods and Blocks
Object Class in Java: equals() and toString()
Interfaces and enum in Java: Object Relationships and Casting
Wrapper Classes in Java
String
Localization
- Internationalization (i18n) and Localization (l10n) in Java
- Java Locale Class: What a Locale Is and How to Create One
- Java ResourceBundle Class: Loading Localized Resources
- Java NumberFormat Class: Formatting Numbers, Currency and Percentages
- MessageFormat in Java: Locale-Sensitive Messages with Parameters
Date & Time
- Java Date and Time API: java.time and the Current Date
- Java LocalDate Class: Methods and Examples
- Java LocalTime Class: Current Time, Formatting and Methods
- Java LocalDateTime Class: Creation, Formatting and Examples
- Instant in Java: the java.time.Instant Class Explained
- ZonedDateTime in Java: ZoneId, Time Zones and Daylight Saving Time
- DateTimeFormatter in Java: Formatting and Parsing Dates with Patterns
Generics & Inner Classes in Java
Lambda Expressions in Java: Syntax and Examples
Collections
- Java Collections Framework: Collection Hierarchy and Interfaces
- Data Structures in Java: List, Stack, Queue and Set
- Collection Interface in Java: Methods and Contract
- List Interface and ArrayList in Java
- Set Interface in Java: HashSet and LinkedHashSet
- Comparable and Comparator Interfaces in Java
- SortedSet, NavigableSet and TreeSet in Java
- Queue and Deque Interfaces in Java
- ArrayDeque Class in Java
- LinkedList Class in Java
- PriorityQueue Class in Java
- Iterator and ListIterator in Java
- Java Map Interface: Methods, Map.Entry and Examples
- HashMap in Java: How It Works Internally
- TreeMap, SortedMap and NavigableMap in Java
- LinkedHashMap in Java: How It Works and LRU Cache
- Sequenced Collections in Java 21: SequencedCollection, SequencedSet and SequencedMap
- Collections Class in Java: Methods and Examples
- Backed Collections and Array-Backed Lists in Java
- Legacy Classes in Java: Vector, Stack, Hashtable and Enumeration
- What Is PECS in Java? Producer Extends, Consumer Super
Records, Sealed, Immutable Classes
Java Stream API: Complete Guide with Examples
- What is Stream API in Java
- Java Stream API Methods: Terminal and Intermediate Operations
- Java Stream flatMap and Stream.concat: Flattening and Combining Streams
- Java Collectors Class: Methods with Examples
- Stream Gatherers in Java: the gather() Method
-
Convert int Array to List
and Back in Java - Optional Methods in Java
- Optional Class in Java: What It Is and Why You Need It
Sorting Algorithms in Java: Basics and Examples
Exceptions
- Java Exceptions and Exception Handling
- Java Exception Hierarchy: Throwable, Error, Exception
- How to Create a Custom Exception in Java
- Java Try Catch Finally: Exception Handling with Examples
- throw and throws in Java: Difference and Examples
- Exception Handling with Method Overriding and Constructors in Java
- Common Exceptions in Java: Causes and How to Fix Them
- Exception Handling in Java: Best Practices and Common Mistakes
File Navigation and I/O
- Java I/O Streams: Input, Output and Wrapping (Decorator) Explained
- Try-with-resources in Java
- Java File Class: Working with Files and Directories
- Java Byte Streams: InputStream and OutputStream
- Java Character Streams: Reader and Writer
- Java Standard Streams: System.in, System.out and System.err
- Java Scanner Class: Reading Files, Strings and Parsing Tokens
- Java NIO.2: Working with Files Using Path and Files
Reflection & Java Doc
Serialization
Threads
- Multithreading in Java: Processes and Threads
- Runnable and Thread in Java: How to Create a Thread
- Daemon Thread in Java: setDaemon() and When the JVM Exits
- Thread States in Java: The Thread Lifecycle
- Thread Priority and the Thread Scheduler in Java
- Thread.sleep() in Java: How to Pause a Thread
- Thread.yield() in Java: What It Does and When to Use It
- Thread.join() and isAlive() in Java
- Thread Interruption in Java: interrupt() and How to Stop a Thread
- Thread Synchronization in Java: synchronized and Monitors
- volatile in Java: Java Memory Model and happens-before
- Deadlock in Java: What It Is and How to Avoid It
- wait(), notify() and notifyAll() in Java: Inter-Thread Communication
- Thread Safety in Java: Thread-Safe Classes and Collections
- ExecutorService in Java: Thread Pool, Callable and Future
- Concurrent Collections in Java: ConcurrentHashMap, CopyOnWriteArrayList, BlockingQueue
- CompletableFuture in Java: Chaining Asynchronous Tasks
- ReentrantLock and the Lock Interface in Java: tryLock, ReadWriteLock, Condition
- Java Synchronizers: CountDownLatch, CyclicBarrier, Semaphore
- Virtual Threads in Java: What They Are and How to Use Them
Git and GitHub for Beginners: Version Control Basics
Maven
- What Is Maven? Purpose, Advantages and Disadvantages
- How to Install Maven on Windows, Linux and macOS
- How to Create a Maven Project: Archetype, Directory Layout and IntelliJ IDEA
- Maven pom.xml Explained: Structure, GAV, Properties, Packaging and Build
- Maven Dependencies: Scope, Transitive Dependencies, Version Conflicts and BOM
- Maven Build Lifecycle: Phases, Plugin Goals and Build Commands
- Maven Plugins: Declaration, Configuration, Executions and Common Plugins
- Maven Repository Types: Local (.m2), Maven Central and Corporate
- Maven Multi-Module Project: Inheritance, Aggregation and Reactor
- Maven Profiles: Declaration, Activation, -P and activeByDefault
SQL
- Relational Databases and DBMS: Basics and Running MySQL
- Keys and Relationships Between Tables in SQL
- Database Normalization and Normal Forms
- MySQL Data Types: Reference Table and Java Mapping
- SQL DDL Commands: CREATE TABLE, ALTER TABLE, DROP and TRUNCATE
- SQL INSERT, UPDATE and DELETE: DML Commands in MySQL
- SQL SELECT Statement: Querying Data from a Table
- SQL Aggregate Functions, GROUP BY and HAVING
- SQL JOIN Types and UNION with Examples
- SQL Subqueries: Scalar, IN, EXISTS and Correlated Subqueries
- SQL Functions in MySQL: String, Numeric and Date Functions
- CASE WHEN, IF, COALESCE, IFNULL and NULLIF in SQL (MySQL)
- SQL Indexes: B-Tree, Composite Indexes, EXPLAIN and Why an Index Is Not Used
- SQL Transactions: ACID, COMMIT and ROLLBACK, Isolation Levels and Anomalies
JDBC
Java Modules (JPMS): Build and Run
- Java Modules: module-info, requires, exports and opens
- Java Services: provides, uses and ServiceLoader
- Module Import Declarations in Java: import module
- Java Runtime Images: jlink, Modular JARs and jdeps
- Compact Source Files and Instance Main Methods in Java 25
- Migrating to Java Modules: Unnamed and Automatic Modules
Frequently Asked Questions
Is the Java online test free?
Yes. Both the Java online test and the interview questions are free and work without registration. If you sign in, your test results are saved to your profile.
What is the difference between the test and the interview questions?
The test checks you: you answer multiple-choice questions and get a score with a review of the correct answers at the end. The interview questions help you revise: you read a question, answer it yourself and reveal the answer right away, without a score.
How many questions are there?
The Java Core course has 1618 test questions and 1332 interview questions across 30 modules. In one session you choose the topics and take from 5 to 100 questions.
What Java topics are covered?
The questions follow the Java Core course: what Java is and your first program, syntax and data types, operators and control flow, arrays, OOP, the static keyword, the Object class, interfaces and enums, wrapper classes, lambdas, the Stream API, sorting algorithms, inner classes and exceptions, and Git. The full list of modules and lessons is on this page.
Is it suitable for beginners or experienced developers?
Both. Beginners can test one lesson right after studying it, while experienced developers can pick several modules to find gaps before an interview. Since you choose the topics yourself, the test is as easy or as hard as the modules you select.
Will I see the correct answers?
Yes. After the test you see every question, your answer and the correct answer, so you know exactly which topics to review. Interview questions show the answer as soon as you open it.
Can it help me prepare for a Java assessment test at work?
It covers the Java Core topics that most technical assessments and interviews check, with code-based questions on compilation, output and errors. Use the test to find weak topics and the interview questions to revise them.