Browse Oracle Certification Guides

Java 17 1Z0-829 Cheat Sheet: Developer Traps

Java 17 1Z0-829 cheat sheet for Java developer traps, APIs, code reading, 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 come from skipping one type, one bound, or one API contract.

1Z0-829 answer sequence

Use this when the stem mixes compile-time legality, declared type, collections, streams, or modern Java features.

    flowchart TD
	  S["Snippet or scenario"] --> C["Does it compile?"]
	  C --> T["What is the exact declared type?"]
	  T --> L["Check language, collection, or stream contract"]
	  L --> R["Predict output, mutation, or exception"]

Read every snippet in this order

  1. Does it compile?
  2. What is the exact declared type on every side?
  3. Which contract is really under test: language rule, collection rule, stream rule, exception rule, or module rule?
  4. Only then predict output, mutation, ordering, or thrown exception.

Compile-vs-runtime triage

Ask this first Why it matters
Does the code compile at all? many distractors disappear before runtime
What is the exact declared type? overload choice, method visibility, and generics depend on it
Is the object mutable, fixed-size, or unmodifiable? collection questions often hide here
Is the stream already consumed? streams are single-use pipelines
Is the exception checked or unchecked? the handling requirement changes immediately

Type and assignment reminders

Rule lane Fast reminder
declaration vs runtime type method visibility and overload choice start from the declared type
numeric literal default integral literals default to int, decimal literals to double
cast legality a cast can compile and still fail at runtime
wrapper null unboxing a null wrapper throws NullPointerException
var local-only and initializer-driven; it does not mean dynamic typing

Overload and conversion order

Rule lane Fast reminder
exact match strongest candidate when legal
primitive widening often chosen before boxing
boxing and unboxing legal, but can create ambiguity or NullPointerException
varargs fallback applicability lane
compound assignment may include implicit cast behavior that plain assignment rejects

Modern Java 17 feature-status map

Feature Status to remember
records permanent
sealed classes and interfaces permanent
pattern matching for instanceof permanent
switch expressions permanent
text blocks permanent

Java 17 feature quick map

Feature Best recall
record concise data carrier with generated members
sealed restricts who may extend or implement
text block multiline string syntax that still yields a String
modern switch value-producing switch expressions with yield
pattern matching for instanceof type test plus safe binding

Flow and pattern reminders

Topic Fast rule
switch expression every reachable path must yield a value or throw
pattern variable scope usable only where the match is definitely true
fall-through instinct old switch habits often break modern switch reasoning
yield returns a value from a block switch arm, not from the method
guarded logic resolve legality first, then branch result

Classes, records, and inheritance

Topic Better recall
constructor chain this(...) or super(...) comes first in a constructor
record constructor compact constructor validates or normalizes state
override legality check access, return type, throws, and static/instance mismatch
default-method conflict class wins, then most-specific interface logic applies
sealed hierarchy permitted subtypes must obey the sealing rules exactly

Collections and generics chooser

Requirement Strongest first recall
immutable factory list List.of(...)
fixed-size list backed by array Arrays.asList(...)
producer source ? extends T
consumer sink ? super T
generic type relationship invariance still applies
ordered result assumptions use the actual collection contract, not habit

Collections and generics traps

Trap Better rule
Arrays.asList(...) is immutable it is fixed-size, not fully unmodifiable
List.of(...) behaves like ArrayList it is unmodifiable and rejects null
List<Child> is a subtype of List<Parent> generics are invariant
wildcard direction is cosmetic extends reads from a producer, super writes to a consumer
set/list order is obvious from variable name trust the implementation contract only

Streams, Optional, and collectors

Requirement Strongest first fit
transform each element map
keep only matching elements filter
flatten nested sources flatMap
group or reduce to a result shape collector choice matters
absent value handling Optional is not a collection and not a null wrapper hack
parallel use only when order and shared-state assumptions still hold

Stream contract reminders

Topic Fast rule
stream reuse a stream pipeline is single-use
map vs flatMap map transforms elements; flatMap flattens nested sources
encounter order preserved only where the source and operations preserve it
collector choice terminal result shape depends on the collector, not on wishful thinking
side effects unsafe side effects make parallel reasoning worse, not better

Optional reminders

Topic Fast rule
Optional.get() unsafe unless presence is already guaranteed
orElse vs orElseGet eager argument evaluation versus lazy supplier
map vs flatMap on Optional same nesting logic problem as streams
Optional fields usually a design smell in ordinary domain classes

Exceptions, modules, and concurrency

Topic Fast rule
checked exception must be caught or declared
try-with-resources resources close automatically in reverse declaration order
assertion for internal correctness checks, not normal public flow control
JPMS requires declares module dependency readability
JPMS exports exposes a package to other modules
executor manages task submission and execution strategy
synchronized mutual exclusion and visibility boundary

Exceptions and resources reminders

Topic Fast rule
checked exception part of method-contract reasoning
unchecked exception still real, just not forced in the signature
multi-catch caught variable is effectively final
try-with-resources close order is reverse declaration order
suppressed exception can matter when close and body both fail

Modules and packaging reminders

Topic Fast rule
module-info.java module declaration root
requires transitive exports readability through a dependency chain
opens reflective access lane, not the same as exports
automatic module jar on module path without explicit descriptor
class path vs module path do not blend the two mentally

Concurrency reminders

Topic Fast rule
ExecutorService separates task submission from thread creation details
Future result placeholder with timing/blocking implications
race condition correctness bug, not just performance noise
synchronized visibility plus exclusion, not a performance feature
concurrent collection helps with access patterns but does not replace whole-design thinking

Final stop-before-submit prompts

  • Did I separate compile from runtime?
  • Did I decide the declared type before following the code?
  • Did I confuse fixed-size with unmodifiable?
  • Did I assume stream or collection order without checking the contract?
  • Did I answer a behavior question before resolving legality?
Revised on Sunday, May 10, 2026