11 - Final Revision and Cheat Sheet
The ultimate 7-day Oracle Certified Professional: Java SE 21 Developer (1Z0-830) revision guide. Everything you need to remember, consolidated.
Table of Contents
- 7-Day Study Plan
- Exam Overview
- Java Fundamentals Summary
- Data Types & Operators Summary
- Control Flow Summary
- OOP Summary
- Records, Sealed, Pattern Matching
- Exceptions Summary
- Collections & Generics Summary
- Streams & Lambdas Summary
- Concurrency & Virtual Threads Summary
- Compilation Traps
- Runtime Exception Traps
- Output Prediction Shortcuts
- Memory Tricks & Mnemonics
- Quick Reference Tables
- Top 100 Concepts to Remember
- Exam-Day Strategy
- Final One-Page Cheat Sheet
1. 7-Day Study Plan
| Day | Focus | Files |
|---|
| 1 | Fundamentals, data types, operators | 01, 02 |
| 2 | Control flow, classes & methods | 03, 04 |
| 3 | OOP, inheritance, polymorphism | 05 |
| 4 | Interfaces, records, sealed classes | 06 |
| 5 | Exceptions, collections, generics | 07, 08 |
| 6 | Streams, lambdas, concurrency | 09, 10 |
| 7 | This revision guide + practice tests | 11 |
Rule: Practice timed mock exams daily. Review every wrong answer until you know why each option is right or wrong.
2. Exam Overview
| Item | Detail |
|---|
| Exam code | 1Z0-830 |
| Title | Oracle Certified Professional: Java SE 21 Developer |
| Questions | ~50 multiple choice |
| Duration | ~90 minutes |
| Passing score | ~68% (verify on Oracle's site) |
| Style | Code analysis, output prediction, "what happens" |
| Key trait | Many questions have "Compilation fails" / "Runtime exception" options |
Roughly 1.8 minutes per question — pace yourself.
3. Java Fundamentals Summary
- JDK = JRE + dev tools; JRE = JVM + libraries; JVM runs bytecode.
javac File.java → bytecode; java File runs it (no .class). Java 11+: java File.java runs source directly.
- One public top-level type per file; file name = public class name.
- Source order:
package → import → type.
main: public static void main(String[] args) (also String...).
java.lang is auto-imported; wildcard imports are not recursive.
- Local variables have no default; fields default to
0/false/null.
var = local inference only; needs initializer; no null, no fields/params.
- Access:
private < default < protected < public.
- Init order: static (once) → instance fields/blocks → constructor; parent before child.
4. Data Types & Operators Summary
- 8 primitives:
byte short int long float double char boolean.
long needs L; float needs f; underscores only between digits.
- Wrapper cache:
Integer -128..127 → == true; outside → false. Use .equals().
- Unboxing
null → NPE. Boxing + widening together is not allowed.
- Widening auto (
int→long→float→double); narrowing needs a cast (truncates, wraps).
- Compound assignment (
+=) hides an implicit cast.
byte/short/char promote to int in arithmetic; 'A'+'B' = 131.
5/2=2; 1/0 throws; 1.0/0=Infinity; 0.0/0.0=NaN; NaN==NaN=false.
String immutable + pooled; new String = heap object.
StringBuilder mutable, no equals() override.
5. Control Flow Summary
if needs boolean; if(x=5) fails for ints.
- Classic
switch falls through without break; allows int/char/String/enum, not long/float/double/boolean.
switch expression (->): no fall-through, must be exhaustive, yield for blocks.
- Java 21 pattern switch: type patterns,
when guards, record deconstruction, case null; order/dominance enforced.
- Sealed types let
switch be exhaustive without default.
while(false){} = unreachable compile error; if(false){} is fine.
- for-each variable is a copy; no index; can't structurally modify.
do-while needs a trailing ;.
- Labels:
break label; / continue label; to target outer loops.
6. OOP Summary
- Single class inheritance (
extends); multiple interface implementation.
- Constructors and
private members are not inherited.
this()/super() must be the first constructor statement; implicit super() inserted otherwise.
- Parent without no-arg constructor → child must call
super(args).
- Overriding: same signature, same/covariant return, same-or-wider access, same/narrower/no checked exceptions; runtime binding.
- Overloading: different params; compile-time binding; return-type-only = error.
- Only instance methods are polymorphic; fields & static methods are hidden (resolved by reference type).
- Upcast implicit/safe; downcast explicit, risks
ClassCastException.
null instanceof X → false; pattern matching: if (o instanceof String s).
- Override
equals + hashCode together.
abstract + final = illegal; final: class (no extend), method (no override), var (assign once).
7. Records, Sealed, Pattern Matching
Records (Java 16+)
record Point(int x, int y) {} → auto fields, ctor, accessors x(), equals, hashCode, toString.
- Implicitly
final; extends Record → can't extend a class; can implement interfaces.
- Accessor is
x() not getX().
- Compact constructor:
Point { ... } (no params, validates, auto-assigns).
- Can have static fields/methods; no extra instance fields.
- Extra constructors must delegate via
this(...).
Sealed Classes (Java 17+)
sealed interface Shape permits Circle, Square {}.
- Every permitted subtype must be
final, sealed, or non-sealed.
permits optional if all subtypes are in the same file.
- Records fit (they're final).
Pattern Matching (Java 21)
instanceof patterns: if (o instanceof Point(int x, int y)).
- Switch patterns + guards:
case Integer i when i > 100 ->.
- Record deconstruction, nestable:
case Line(Point(var x1,var y1), Point(var x2,var y2)).
case null handles null (else NPE).
- Sealed + switch = exhaustive, no
default needed; dominance errors at compile time.
8. Exceptions Summary
Throwable → Error (unchecked) + Exception.
- Checked = compile-time checked, must catch/declare (
IOException, SQLException).
- Unchecked =
RuntimeException/Error subclasses (NPE, Arithmetic, ClassCast, IndexOOB).
- Never catch
Error. try needs catch/finally/resource.
- Catch order: specific → general; reverse = compile error.
- Multi-catch: disjoint types only; variable effectively final.
finally always runs except System.exit()/JVM crash; return in finally overrides.
- try-with-resources:
AutoCloseable, closes reverse order, before catch/finally; close exceptions suppressed.
throw raises; throws declares; throw null → NPE.
- Catching a checked exception never thrown = compile error (not for runtime types).
- Overriding can't broaden checked exceptions.
9. Collections & Generics Summary
Iterable→Collection→List/Set/Queue; Map is separate.
List: ordered, duplicates, index. ArrayList (fast random) vs LinkedList (fast ends, is a Deque).
Set: unique. HashSet (unordered), LinkedHashSet (insertion), TreeSet (sorted, no null, needs ordering).
Map: HashMap (unordered, 1 null key), LinkedHashMap (insertion), TreeMap (sorted, no null key).
- Queue:
offer/poll/peek (safe) vs add/remove/element (throw). ArrayDeque for stacks.
Comparable = natural (compareTo); Comparator = custom (compare, chainable).
- Generics: compile-time safety; diamond
<>; bounded <T extends Number> (class first in multiple bounds).
- PECS: Producer
extends (read), Consumer super (write). Can't add to <? extends T>.
- Type erasure: no
new T(), new T[], List<int>, instanceof List<String>.
List.of/Set.of/Map.of = immutable, null-hostile.
removeIf/Iterator.remove to avoid ConcurrentModificationException.
10. Streams & Lambdas Summary
- Lambda = anonymous SAM implementation; captures effectively final locals.
- Functional interface = exactly one abstract method.
- Core:
Supplier(get), Consumer(accept), Function(apply), Predicate(test).
andThen = this→arg; compose = arg→this.
- Method refs:
Class::static, obj::m, Class::m, Class::new.
- Streams: lazy, single-use (reuse →
IllegalStateException), non-mutating.
- Intermediate (lazy):
filter map flatMap distinct sorted limit skip peek.
- Terminal (eager):
forEach collect toList reduce count *Match find* min max.
iterate/generate are infinite → need limit.
- Elements flow one at a time; short-circuit ops stop early.
- Collectors:
toList/toSet/toMap(+merge), joining, groupingBy(+downstream), partitioningBy.
toMap duplicate keys → need merge fn.
Optional: of/ofNullable/empty; orElse always evaluates, orElseGet is lazy; avoid get().
11. Concurrency & Virtual Threads Summary
start() spawns a thread; run() doesn't; start() twice → IllegalThreadStateException.
- Lifecycle: NEW → RUNNABLE → (BLOCKED/WAITING/TIMED_WAITING) → TERMINATED.
- Race condition:
count++ not atomic. Fix via synchronized/Lock/Atomic.
synchronized = mutual exclusion + visibility; volatile = visibility only.
wait/notify inside synchronized (else IllegalMonitorStateException); sleep keeps locks, wait releases.
ReentrantLock: lock/unlock (finally!), tryLock, fairness, conditions.
- Deadlock = 4 Coffman conditions; fix with lock ordering.
- Executors: fixed/cached/single/scheduled/virtual-per-task; always
shutdown().
Runnable (void, no checked) vs Callable (value + checked).
Future.get() blocks; CompletableFuture chains (thenApply/thenCompose/thenCombine/exceptionally).
- Concurrent:
ConcurrentHashMap (no null), CopyOnWriteArrayList, BlockingQueue.
- Atomics: lock-free CAS (
AtomicInteger).
- Virtual threads (21): millions cheap;
Thread.ofVirtual(), newVirtualThreadPerTaskExecutor(); don't pool; synchronized pins → prefer ReentrantLock.
12. Compilation Traps
| # | Code situation | Result |
|---|
| 1 | Two public classes in one file | Compile error |
| 2 | package after import | Compile error |
| 3 | Local variable used before init | Compile error |
| 4 | int x = 5; if (x) {} | Compile error (not boolean) |
| 5 | Overloading by return type only | Compile error |
| 6 | this()/super() not first in ctor | Compile error |
| 7 | Reducing visibility when overriding | Compile error |
| 8 | Broader checked exception in override | Compile error |
| 9 | Subclass catch after superclass catch | Compile error (unreachable) |
| 10 | Multi-catch with related types | Compile error |
| 11 | Catching checked exception never thrown | Compile error |
| 12 | Code after unconditional throw/return | Unreachable — compile error |
| 13 | while(false) { stmt; } | Unreachable — compile error |
| 14 | switch expression not exhaustive | Compile error |
| 15 | Adding to List<? extends T> | Compile error |
| 16 | Long l = 5; (boxing + widening) | Compile error |
| 17 | var x; or var x = null; | Compile error |
| 18 | Missing super(args) for param-only parent | Compile error |
| 19 | Sealed subtype missing modifier | Compile error |
| 20 | byte b = b + 1; (int result) | Compile error |
13. Runtime Exception Traps
| # | Code | Exception |
|---|
| 1 | null.method() | NullPointerException |
| 2 | Unboxing null Integer | NullPointerException |
| 3 | arr[arr.length] | ArrayIndexOutOfBoundsException |
| 4 | "abc".charAt(5) | StringIndexOutOfBoundsException |
| 5 | 5 / 0 (int) | ArithmeticException |
| 6 | (String) anInteger | ClassCastException |
| 7 | Integer.parseInt("x") | NumberFormatException |
| 8 | List.of(1).add(2) | UnsupportedOperationException |
| 9 | Modify in for-each | ConcurrentModificationException |
| 10 | Optional.empty().get() | NoSuchElementException |
| 11 | Optional.of(null) | NullPointerException |
| 12 | Reuse a consumed stream | IllegalStateException |
| 13 | toMap duplicate keys | IllegalStateException |
| 14 | wait() outside synchronized | IllegalMonitorStateException |
| 15 | start() a thread twice | IllegalThreadStateException |
| 16 | TreeSet.add(null) | NullPointerException |
| 17 | main(String args) no [] | "Main method not found" (not an exception per se) |
| 18 | Deep recursion | StackOverflowError |
| 19 | throw null; | NullPointerException |
| 20 | ConcurrentHashMap.put(null, x) | NullPointerException |
14. Output Prediction Shortcuts
Integer Cache
Integer a = 127, b = 127;
Integer c = 128, d = 128;
String Pool
"hi" == "hi"
"hi" == new String("hi")
"hi".equals(new String("hi"))
Char Arithmetic
'A' + 'B'
"" + 'A' + 'B'
1 + 2 + "x"
"x" + 1 + 2
Increment
int i = 5;
i++
++i
int a=1; int b = a++ + ++a;
Initialization Order
static field/block (once) -> instance field/block -> constructor
parent before child
finally Override
try { return 1; } finally { return 2; }
Division
5/2
5.0/2
1/0
1.0/0
0.0/0.0
Field vs Method Polymorphism
Parent p = new Child();
p.x
p.method()
p.staticM()
15. Memory Tricks & Mnemonics
| Mnemonic | Meaning |
|---|
| PECS | Producer Extends, Consumer Super (wildcards). |
| "Class wins" | Concrete class method beats interface default. |
| SIC | Static → Instance → Constructor (init order). |
| "Specific before General" | catch block ordering. |
| "Widen, Box, Var" | Overload resolution: widening → autoboxing → varargs. |
| "127 friends" | Integer cache range -128..127 → == true. |
| "Reverse Close" | try-with-resources closes in reverse order. |
| CHILD-er throws less | Override: narrower/equal checked exceptions only. |
| "Final First" | this()/super() must be the first statement. |
| "Lazy Streams Wake on Terminal" | Nothing runs until a terminal op. |
| "Volatile = Visible, not Vault" | volatile gives visibility, not atomicity. |
| "Don't Pool the Virtuals" | One virtual thread per task. |
| MILES | Map Is a separate hierarchy (not a Collection). |
| "Sleep keeps, Wait waves" | sleep keeps locks; wait releases them. |
| TUNA | Tree types: no null, Unique, Navigable, sorted (Auto). |
16. Quick Reference Tables
Access Modifiers
| Modifier | Class | Package | Subclass | World |
|---|
private | ✅ | ❌ | ❌ | ❌ |
| default | ✅ | ✅ | ❌ | ❌ |
protected | ✅ | ✅ | ✅ | ❌ |
public | ✅ | ✅ | ✅ | ✅ |
Collection Null Support
| Type | Null Key/Element |
|---|
HashMap / HashSet | One null allowed |
TreeMap / TreeSet | ❌ NPE |
ConcurrentHashMap | ❌ NPE |
List.of / Set.of | ❌ NPE |
Functional Interfaces
| Interface | Method | In → Out |
|---|
Supplier<T> | get | () → T |
Consumer<T> | accept | T → void |
Function<T,R> | apply | T → R |
Predicate<T> | test | T → boolean |
UnaryOperator<T> | apply | T → T |
BinaryOperator<T> | apply | (T,T) → T |
Switch-Allowed Types
| Allowed | Not Allowed |
|---|
byte short char int + wrappers | long float double boolean |
String, enum | (classic switch) |
Big-O Quick Glance
| Structure | get | add | contains |
|---|
| ArrayList | O(1) | O(1)* | O(n) |
| LinkedList | O(n) | O(1) | O(n) |
| HashMap/HashSet | O(1) | O(1) | O(1) |
| TreeMap/TreeSet | O(log n) | O(log n) | O(log n) |
17. Top 100 Concepts to Remember
- JDK ⊃ JRE ⊃ JVM.
javac compiles to bytecode; JVM runs it.
java File.java runs source directly (Java 11+).
- One public type per file; file name matches it.
- Source order: package → import → type.
main(String[] args) is the entry point.
java.lang is auto-imported.
- Wildcard imports are not recursive.
- Local variables have no defaults.
- Fields default to 0/false/null.
var is local-only, needs initializer.
- Access: private < default < protected < public.
- Init order: static → instance → constructor.
- Parent initializes before child.
- 8 primitive types exist.
long=L, float=f suffixes.
- Underscores only between digits.
- Integer cache: -128..127 →
== true.
- Unboxing null → NPE.
- No boxing + widening together.
- Widening auto; narrowing needs cast.
- Narrowing truncates and wraps.
- Compound assignment hides a cast.
byte/short/char promote to int.
'A'+'B' = 131.
1/0 throws; 1.0/0 = Infinity.
NaN == NaN is false.
- String is immutable and pooled.
new String is a heap object.
- StringBuilder has no equals override.
if requires boolean.
- Classic switch falls through.
- Switch rejects long/float/double/boolean.
- Switch expression must be exhaustive.
- Arrow switch has no fall-through.
yield returns from a switch block.
- Pattern switch needs
case null for null.
- Pattern dominance errors at compile time.
- Sealed enables exhaustive switch.
while(false){} is a compile error.
- for-each variable is a copy.
do-while needs trailing ;.
- Labels target outer loops.
- Single class inheritance only.
- Constructors aren't inherited.
this()/super() must be first.
- Implicit
super() is inserted.
- Param-only parent forces
super(args).
- Overriding: same/covariant return.
- Overriding: same or wider access.
- Overriding: narrower/no checked exceptions.
- Overloading: compile-time binding.
- Return-type-only overload = error.
- Only instance methods are polymorphic.
- Fields and statics are hidden (reference type).
- Upcast is implicit; downcast explicit.
- Bad downcast → ClassCastException.
null instanceof X is false.
- Override equals + hashCode together.
- abstract + final is illegal.
- final: class/method/variable rules.
- Records are implicitly final.
- Record accessor is
x() not getX().
- Records can't extend classes.
- Compact constructor validates.
- Sealed subtypes: final/sealed/non-sealed.
- permits optional if same file.
- Record patterns deconstruct.
instanceof String s binds a variable.
- Throwable → Error + Exception.
- Checked must catch or declare.
- Unchecked = RuntimeException/Error.
- Never catch Error.
- catch order: specific → general.
- Multi-catch types must be disjoint.
finally overrides via return.
- try-with-resources closes in reverse.
- Close exceptions are suppressed.
throw null → NPE.
- Map is not a Collection.
- TreeSet/TreeMap reject null keys.
- PECS: producer extends, consumer super.
- Can't add to
<? extends T>.
- Type erasure removes generics at runtime.
List.of is immutable.
- removeIf avoids ConcurrentModificationException.
- Streams are lazy and single-use.
- iterate/generate need limit.
orElse always evaluates; orElseGet lazy.
Optional.get() on empty throws.
- toMap duplicate keys need merge fn.
start() spawns; run() doesn't.
- volatile = visibility only.
- wait/notify need synchronized.
- Deadlock = 4 conditions; fix lock order.
- Callable returns + throws; Runnable doesn't.
Future.get() blocks.
- ConcurrentHashMap forbids nulls.
- Virtual threads: don't pool.
synchronized pins virtual threads → use ReentrantLock.
18. Exam-Day Strategy
Before the Exam
- Sleep well; arrive/login early.
- Quickly re-read this guide's cheat sheets (Sections 12–16).
- Keep a glass of water; stay calm.
During the Exam
| Strategy | Detail |
|---|
| Read carefully | Watch for "compiles", "runtime exception", "no output". |
| Check imports & signatures | Many traps hide in missing imports or wrong main. |
| Scan for compile errors first | If it doesn't compile, runtime answers are wrong. |
| Eliminate options | Remove clearly wrong ones to improve odds. |
| Flag and move on | Don't burn time; revisit flagged questions. |
| Trace code on scratch paper | Track variable values and init order. |
| Watch the clock | ~1.8 min/question; leave time to review. |
| Answer everything | No penalty for guessing — never leave blanks. |
Code-Reading Checklist (per question)
- Does it compile? (signatures, types, access, exceptions)
- Any unreachable code or uninitialized locals?
- Initialization order for output questions.
- Reference type vs object type for field/method/static.
- Autoboxing / Integer cache / String pool for
==.
- Checked exceptions caught or declared?
- For streams: lazy? single-use? terminal present?
Common Distractor Patterns
- "Compilation fails" when it actually runs (and vice versa).
- Output with subtle off-by-one or fall-through.
== vs .equals() on wrappers/strings.
- An overridden method that looks overloaded (or vice versa).
19. Final One-Page Cheat Sheet
================ OCP JAVA SE 21 (1Z0-830) FINAL CHEAT SHEET ================
FUNDAMENTALS
JDK>JRE>JVM ; javac->bytecode ; java File / java File.java(11+)
1 public type/file = filename ; order package->import->type
locals no default ; fields 0/false/null ; var local-only+init
access: private<default<protected<public
INIT: static(once)->instance fields/blocks->ctor ; parent first
DATA TYPES
8 primitives ; long=L float=f ; underscore between digits
Integer cache -128..127 (== true) ; unbox null -> NPE
no box+widen ; widen auto, narrow cast(truncate/wrap)
b+=1 ok, b=b+1 err ; 'A'+'B'=131 ; 1/0 throw 1.0/0 Inf NaN!=NaN
String immutable/pooled ; StringBuilder no equals()
CONTROL FLOW
if needs boolean ; classic switch falls through
switch no long/float/double/boolean ; expr exhaustive, yield
pattern switch(21): when guards, records, case null, dominance
while(false){}=err ; for-each var=copy ; do-while needs ;
OOP
single extends ; ctor/private not inherited ; this()/super() first
override: covariant return, wider access, narrower checked, runtime
overload: diff params, compile-time ; only INSTANCE methods polymorphic
fields+static = hidden (ref type) ; downcast->CCE ; null instanceof=false
equals+hashCode together ; abstract+final illegal
RECORDS/SEALED/PATTERNS (16/17/21)
record P(int x){} final, x() accessor, compact ctor, no class extend
sealed ... permits ; subtype final/sealed/non-sealed
if(o instanceof P(int x)) ; switch case P(var x) when... ; case null
sealed+switch = exhaustive (no default)
EXCEPTIONS
Throwable->Error(unchecked)+Exception ; checked must catch/declare
catch specific->general ; multi-catch disjoint ; finally overrides
try-with-resources: AutoCloseable, reverse close, suppressed
throw null->NPE ; override no broader checked
COLLECTIONS/GENERICS
Map NOT a Collection ; ArrayList(random) LinkedList(ends/Deque)
Hash(unordered) Linked(insertion) Tree(sorted,no null)
offer/poll/peek vs add/remove/element ; ArrayDeque=stack
Comparable(compareTo) Comparator(compare,chain)
PECS: extends=read, super=write ; erasure no new T()/T[]/List<int>
List.of immutable ; removeIf avoids CME
STREAMS/LAMBDAS
lazy, single-use ; Supplier/Consumer/Function/Predicate
andThen=this->arg compose=arg->this ; Class::new
intermediate filter/map/flatMap/distinct/sorted/limit/peek
terminal collect/reduce/count/match/find ; iterate needs limit
groupingBy/partitioningBy/toMap(merge) ; orElse eval / orElseGet lazy
CONCURRENCY/VIRTUAL (21)
start() spawns, run() no ; volatile=visibility only
synchronized + wait/notify ; ReentrantLock(finally unlock)
deadlock=4 conds(lock order) ; Runnable(void) Callable(value+checked)
Future.get blocks ; CompletableFuture then* chains
ConcurrentHashMap(no null) ; Atomic CAS
Virtual: Thread.ofVirtual / newVirtualThreadPerTaskExecutor
DON'T pool ; synchronized PINS -> use ReentrantLock
MNEMONICS
PECS | Class wins | SIC(init) | Widen-Box-Var | 127 friends
Reverse Close | Final First | Sleep keeps/Wait waves | Don't Pool Virtuals
===========================================================================
You're ready. Trust your preparation, read each question twice, and watch for the compile-vs-runtime traps. Good luck on the 1Z0-830!
End of 11 - Final Revision and Cheat Sheet.