Free · Java 25 · no sign-up
Java 25 practice test
Original Java SE 25 practice questions on language basics, classes, records, generics, collections, streams, exceptions, concurrency, pattern matching, modules, and Java 25 features. Answers cite the JLS, Java SE 25 API, or a JEP. Not an Oracle exam.
The free timed mock has 50 questions, a 90-minute limit and a 70% pass mark. This is an unofficial practice format, not the format of any certification exam.
Every question is original, written for Java SE 25 and linked to the section of the Java Language Specification, the Java SE 25 API documentation or the JEP it is based on.
- Free, no account
- Every answer cites its source
- No paywall on the full mock
Topics
12% of the mock8 free Classes, records, sealed types and enums
16% of the mock12 free Generics
10% of the mock15 free Collections and streams
14% of the mock14 free Exceptions
8% of the mock9 free Concurrency and virtual threads
10% of the mock14 free Pattern matching and switch
12% of the mock13 free Modules and imports
6% of the mock12 free Java 25 features
12% of the mock12 free
Browse practice questions
Language basics and types (8)
- A developer combines a long and a float in an arithmetic expression. What does this Java 25 program print?
- What does this Java 25 program print when adding an int and a long?
- Given this Java 25 code using a compound assignment on an array element, what does it print?
- How many specific conversions on primitive types are defined as narrowing primitive conversions in Java 25?
- In a numeric context where none of the expressions have type double, float, or long, what determines how the promoted type is chosen?
Practice all 8 Language basics and types questions one at a time
Classes, records, sealed types and enums (12)
- Class A declares a package-access instance method mA. Subclass C is declared in a different package and defines an instance method mC with the same signature. Does mC override mA?
- Class A declares a private instance method mA, and subclass C in the same package declares an instance method mC with the exact same signature. Does mC override mA?
- A developer compares a record instance against an instance of a different record type that happens to have the exact same component names and values. What does the implicitly declared equals(Object) method return?
- A developer creates an interface that extends two superinterfaces, each providing a default method with the same signature, without declaring that method in the subinterface. How does the Java 25 compiler handle this?
- A developer declares an interface method without private, default, or static, and writes an empty block body for it. What happens when compiling this code?
Practice all 12 Classes, records, sealed types and enums questions one at a time
Generics (15)
- According to the JLS SE 25 grammar for TypeParameter, which modifier is permitted directly on a type parameter declaration?
- A developer declares a generic method with type parameters. How does JLS SE 25 describe the set of methods defined by that declaration?
- A developer declares a non-generic interface Auditable with no extends clause. According to JLS SE 25, what is the direct supertype of Auditable?
- A developer examines a generic method declaration and wants to know where its type parameters are specified. Which section form does JLS SE 25 specify?
- A generic class Cache<K, V> declares a method V lookup(K key). In the parameterized type Cache<String, Integer>, how is the type of lookup determined?
Collections and streams (14)
- A developer accidentally inserts a Map into itself as a value. According to the Java SE 25 Map specification, what may happen when calling equals(), hashCode(), toString(), or clone() on that map?
- According to JEP 431, what defines a sequenced collection?
- When the built-in operations on a Stream do not provide the custom traversal behavior a developer needs, which two BaseStream operations can be used for controlled traversal?
- A developer calls contains(null) on a List implementation that prohibits null elements. According to the Java SE 25 List specification, what behavior is permitted?
- A developer is deciding whether to expose a Collection or a Stream from a repository method. According to the Java SE 25 API, what is the primary difference in their goals?
Practice all 14 Collections and streams questions one at a time
Exceptions (9)
- What happens when a developer attempts to compile this Java 25 program?
- What happens when a developer compiles this Java 25 program?
- What happens when this Java 25 program runs?
- A developer is inspecting the Java exception hierarchy to build a custom error-reporting utility. Which class is the direct superclass of Throwable?
- An optimizing JVM speculatively executes expressions that appear after a statement which ends up throwing an exception at runtime. What does the Java Language Specification require regarding those speculatively executed expressions?
Concurrency and virtual threads (14)
- An application passes a security token from a controller through six intermediate service layers to a repository method. What drawback of standard method-parameter passing does ScopedValue<T> help eliminate?
- A backend service can handle at most 20 simultaneous calls to a downstream payment gateway, and the application uses virtual threads. What is the recommended way to enforce that concurrency limit in Java 25?
- How does ExecutorService extend the basic Executor interface in the Java SE 25 standard library?
- How does the Java 25 runtime schedule virtual threads onto physical processor cores?
- A developer needs a concurrency type that can both be completed explicitly with a result and chain dependent actions that trigger upon completion. Which pair of interfaces implemented by CompletableFuture<T> provides these capabilities?
Practice all 14 Concurrency and virtual threads questions one at a time
Pattern matching and switch (13)
- According to the Java Language Specification, how is pattern matching classified relative to statement execution and expression evaluation?
- During run-time evaluation of a switch expression, when does the JVM determine which switch label applies?
- What happens when a developer compiles this Java 25 code?
- What happens when a developer compiles this Java 25 program?
- What happens when a developer compiles this Java 25 program?
Practice all 13 Pattern matching and switch questions one at a time
Modules and imports (12)
- A developer adds `import module com.example.core;` to a compilation unit. Which types from `com.example.core` become available on demand?
- When a compilation unit includes a single-type-import declaration `import TypeName;`, where does the imported type become available under its simple name?
- A team exports `com.acme.model` from their module without adding an `opens` directive. Can another module use reflection to access public types and members in `com.acme.model`?
- What happens if a `requires` directive is placed inside the module declaration of `java.base`?
- A library module declares `exports com.acme.api;` in its module declaration. What compile-time and run-time access does this grant to code in other modules?
Java 25 features (12)
- Which explicit constructor invocation rule applies to a non-canonical constructor of a record class in Java 25?
- A framework binds a request ID to a ScopedValue using run and then invokes application code. When does that binding expire?
- What happens when a developer compiles this Java 25 record?
- Inside a constructor epilogue (after super()), which form of the return statement is permitted in Java 25?
- How does Java 25 change the default imports provided automatically by the JShell tool?
Timed mock exam
The free mock draws 50 questions across the topics above (6/8/5/7/4/5/6/3/6), runs a 90-minute clock and scores you by topic. No account needed. Start the timed mock.
Topic weights: Unofficial practice blueprint (topic weights chosen by setupmycode exams, see tools/tech-pipeline/BLUEPRINTS.md). Written against Java SE 25 (JLS SE 25, Java SE 25 API, JDK 25 JEPs; preview features excluded). It does not mirror any Oracle exam; Oracle's current Java SE developer exam, 1Z0-830, covers Java 21.