Browse Oracle Certification Guides

Java 25 1Z0-831 Cheat Sheet

Java 25 1Z0-831 cheat sheet for key facts, traps, service mappings, and final review.

Use this for last-mile review. The goal is not to relearn Java. The goal is to stop the avoidable misses that happen when you skip one type, one feature-status flag, one stream contract, or one exception rule.

1Z0-831 answer sequence

Use this when the stem mixes compile-time legality, preview status, declared type, or Java 25 feature rules.

    flowchart TD
	  S["Snippet or scenario"] --> P["Is any feature preview-only?"]
	  P --> C["Does it compile?"]
	  C --> T["What is the exact declared type?"]
	  T --> R["Check collection, stream, concurrency, or module contract"]

Read every snippet in this order

  1. Does it compile?
  2. Is any feature preview-only?
  3. What is the exact declared type?
  4. What contract actually runs: collection, stream, concurrency, module, or exception?
  5. Only then predict output, side effect, or thrown exception.

Java 25 feature-status matrix

Feature Java 25 signal to remember
Flexible Constructor Bodies permanent in Java 25
Stream Gatherers permanent API before Java 25; still high-yield for Java 25 stream reasoning
Scoped Values permanent API in Java 25
Structured Concurrency preview API in Java 25
Module Import Declarations preview language feature in Java 25
Compact Source Files / instance main model permanent language feature in Java 25
Primitive types in patterns, instanceof, and switch preview language feature in Java 25

Java 25 status rule

Do not group all “new Java 25” topics together. Some are permanent, some are preview, and some were finalized before Java 25 but are still modern OCP bait. The safe exam habit is:

  1. identify the construct
  2. decide whether it is permanent, preview, or older-final
  3. only then reason about compile flags, runtime flags, and output

Preview-feature rule

Question type Better instinct
code uses preview syntax or API assume preview flags matter unless the official doc says permanent
stem compares new Java 25 features separate permanent features from preview features explicitly
one answer assumes preview APIs are always on treat that as suspicious

Preview launch and compile reminders

Situation Fast reminder
compiling preview code preview code normally needs preview enablement at compile time
running preview code preview-enabled compilation does not remove runtime preview requirements
mixed question stem if one choice ignores preview enablement entirely, pressure-test it hard
exam wording expect preview-status questions to be partly about recognition, not only syntax

Compile-vs-runtime triage

Ask this first Why it matters
does the code compile at all? many distractors disappear before runtime
is the type primitive, wrapper, generic, or inferred? overloads, boxing, and legality depend on it
is the object mutable, fixed-size, or unmodifiable? collection questions often hide here
is the stream single-use and still open? pipeline questions often die here
does any API require preview enablement? Java 25 now has more feature-status traps

Types and expression rules

Rule lane Fast reminder
primitive widening often wins before boxing in overload contests
boxing/unboxing legal but may create ambiguity or NullPointerException
varargs last-resort applicability lane, not first choice
compound assignment can include implicit cast behavior that plain assignment rejects
var local-only, initializer-required, inference-driven
text blocks still String

Flow and pattern rules

Feature Fast rule
switch expression must yield a value on every reachable path
pattern variable only usable where definitely matched
yield returns a value from a block-style switch arm
guard logic evaluate pattern/flow legality before output intuition
primitive pattern features Java 25 preview; keep feature status explicit and do not assume older switch intuition still applies

Constructors, records, and classes

Feature Better recall
record concise data carrier with generated members
compact constructor validates or normalizes record state without repeating parameter list
flexible constructor body some statements may appear before explicit constructor invocation in Java 25
before super(...) code still cannot freely use the instance under construction
this(...) vs super(...) still one explicit constructor invocation path

Constructor triage

Ask first Why it matters
is this a normal class, record, or enum constructor? rules differ by type shape
is there an explicit constructor invocation? that still controls the constructor chain
does pre-invocation code try to touch instance state? that is where many wrong answers start
is the stem testing Java 25 flexibility or older constructor restrictions? many distractors rely on outdated instincts

Inheritance and hierarchy chooser

Requirement Strongest first recall
restricted subtype set sealed / permits
conflict across interfaces resolve default-method rules explicitly
override legality check access, throws, return covariance, and static/instance distinction
enum behavior enums are real types with constructors, fields, and methods

Collections and generics chooser

Requirement Strongest first fit
immutable factory list List.of(...)
fixed-size list backed by array Arrays.asList(...)
preserve encounter order know your source and result type
producer source ? extends T
consumer sink ? super T
generic relationship invariance still applies
first/last style access sequenced collection awareness matters

Streams, collectors, and gatherers

Requirement Strongest first fit
transform each element map
flatten nested sources flatMap
classify and reduce to terminal result collector choice matters
custom intermediate transformation gatherer, not collector
preserve ordering in concurrent mapping know the gatherer or stream contract exactly
simple pipeline efficiency primitive streams can avoid boxing

Gatherers quick map

Gatherer idea Fast reminder
gatherer custom intermediate operation model
built-in examples fold, scan, windowFixed, windowSliding, mapConcurrent
feature status final API by Java 25; do not mark it preview in Java 25 review
parallel behavior do not assume a gatherer parallelizes the same way a collector does
collector vs gatherer collector is terminal reduction; gatherer shapes the stream pipeline before termination

Concurrency quick map

Topic Fast rule
virtual thread lightweight thread model for many blocking tasks
structured concurrency treats related tasks as one unit of work
scoped value bounded context sharing safer than thread-local style
preview trap structured concurrency is preview in Java 25; scoped values are final
synchronized visibility + exclusion boundary, not magical design replacement
happens-before if you cannot explain visibility ordering, your concurrency answer is weak

Concurrency chooser

Requirement Strongest first fit
many blocking tasks with simpler scaling virtual threads
bounded contextual data for a call tree scoped values
related subtasks that should be cancelled or joined together structured concurrency
legacy shared mutable state protection synchronized, locks, or explicit coordination primitives
result aggregation after asynchronous work read the task-lifecycle contract before guessing output

Modules and launch model

Topic Fast rule
requires module dependency
exports package visibility to other modules
automatic module JAR on module path without explicit descriptor
compact source file Java 25 simple-source launch model awareness
module import declaration preview in Java 25; still watch for ambiguous simple names

Launch-model reminders

Situation Better instinct
plain source launch question decide whether it is source-file launch, compact-source usage, or modular launch
module question separate compile path, module path, and package export logic
import-like convenience syntax module imports reduce import noise but can create ambiguity that explicit imports may need to resolve

I/O, formatting, and localization

Topic Fast rule
Path / Files always check whether the method returns a path, a stream, a boolean, or throws
try-with-resources closes resources automatically, usually reverse declaration order
serialization know what actually serializes and what is ignored or transient
locale-sensitive formatting String.format, number/date formatting can vary by locale
bundles resource bundles are localization lookup tools, not arbitrary file magic

Exceptions and logging

Rule Fast reminder
checked exception must be caught or declared
unchecked exception runtime family; not forced in method signature
multi-catch caught variable is effectively final
try-with-resources suppressed exceptions can matter
JUL know logger, level, and handler basics without overcomplicating it

Final stop-before-submit prompts

  • Did I separate compile from runtime?
  • Did I mark preview versus permanent correctly?
  • Did I confuse collector with gatherer?
  • Did I assume topic-wide order instead of partition order style reasoning?
  • Did I answer a performance question when the real issue was correctness?
Revised on Sunday, May 10, 2026