MindIQ Academy

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

  1. 7-Day Study Plan
  2. Exam Overview
  3. Java Fundamentals Summary
  4. Data Types & Operators Summary
  5. Control Flow Summary
  6. OOP Summary
  7. Records, Sealed, Pattern Matching
  8. Exceptions Summary
  9. Collections & Generics Summary
  10. Streams & Lambdas Summary
  11. Concurrency & Virtual Threads Summary
  12. Compilation Traps
  13. Runtime Exception Traps
  14. Output Prediction Shortcuts
  15. Memory Tricks & Mnemonics
  16. Quick Reference Tables
  17. Top 100 Concepts to Remember
  18. Exam-Day Strategy
  19. Final One-Page Cheat Sheet

1. 7-Day Study Plan

DayFocusFiles
1Fundamentals, data types, operators01, 02
2Control flow, classes & methods03, 04
3OOP, inheritance, polymorphism05
4Interfaces, records, sealed classes06
5Exceptions, collections, generics07, 08
6Streams, lambdas, concurrency09, 10
7This revision guide + practice tests11

Rule: Practice timed mock exams daily. Review every wrong answer until you know why each option is right or wrong.


2. Exam Overview

ItemDetail
Exam code1Z0-830
TitleOracle Certified Professional: Java SE 21 Developer
Questions~50 multiple choice
Duration~90 minutes
Passing score~68% (verify on Oracle's site)
StyleCode analysis, output prediction, "what happens"
Key traitMany 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: packageimport → 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 nullNPE. 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 Recordcan'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

  • ThrowableError (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 situationResult
1Two public classes in one fileCompile error
2package after importCompile error
3Local variable used before initCompile error
4int x = 5; if (x) {}Compile error (not boolean)
5Overloading by return type onlyCompile error
6this()/super() not first in ctorCompile error
7Reducing visibility when overridingCompile error
8Broader checked exception in overrideCompile error
9Subclass catch after superclass catchCompile error (unreachable)
10Multi-catch with related typesCompile error
11Catching checked exception never thrownCompile error
12Code after unconditional throw/returnUnreachable — compile error
13while(false) { stmt; }Unreachable — compile error
14switch expression not exhaustiveCompile error
15Adding to List<? extends T>Compile error
16Long l = 5; (boxing + widening)Compile error
17var x; or var x = null;Compile error
18Missing super(args) for param-only parentCompile error
19Sealed subtype missing modifierCompile error
20byte b = b + 1; (int result)Compile error

13. Runtime Exception Traps

#CodeException
1null.method()NullPointerException
2Unboxing null IntegerNullPointerException
3arr[arr.length]ArrayIndexOutOfBoundsException
4"abc".charAt(5)StringIndexOutOfBoundsException
55 / 0 (int)ArithmeticException
6(String) anIntegerClassCastException
7Integer.parseInt("x")NumberFormatException
8List.of(1).add(2)UnsupportedOperationException
9Modify in for-eachConcurrentModificationException
10Optional.empty().get()NoSuchElementException
11Optional.of(null)NullPointerException
12Reuse a consumed streamIllegalStateException
13toMap duplicate keysIllegalStateException
14wait() outside synchronizedIllegalMonitorStateException
15start() a thread twiceIllegalThreadStateException
16TreeSet.add(null)NullPointerException
17main(String args) no []"Main method not found" (not an exception per se)
18Deep recursionStackOverflowError
19throw null;NullPointerException
20ConcurrentHashMap.put(null, x)NullPointerException

14. Output Prediction Shortcuts

Integer Cache

Integer a = 127, b = 127;   // a == b -> true
Integer c = 128, d = 128;   // c == d -> false

String Pool

"hi" == "hi"                 // true (pool)
"hi" == new String("hi")     // false (heap)
"hi".equals(new String("hi"))// true

Char Arithmetic

'A' + 'B'         // 131 (int)
"" + 'A' + 'B'    // "AB" (string concat)
1 + 2 + "x"       // "3x"
"x" + 1 + 2       // "x12"

Increment

int i = 5;
i++ // uses 5 then 6
++i // 6 then uses 6
int a=1; int b = a++ + ++a;  // 1 + 3 = 4, a=3

Initialization Order

static field/block (once) -> instance field/block -> constructor
parent before child

finally Override

try { return 1; } finally { return 2; }   // returns 2

Division

5/2     // 2
5.0/2   // 2.5
1/0     // ArithmeticException
1.0/0   // Infinity
0.0/0.0 // NaN

Field vs Method Polymorphism

Parent p = new Child();
p.x          // Parent's x (field = reference type)
p.method()   // Child's method (instance method = object type)
p.staticM()  // Parent's static (reference type)

15. Memory Tricks & Mnemonics

MnemonicMeaning
PECSProducer Extends, Consumer Super (wildcards).
"Class wins"Concrete class method beats interface default.
SICStatic → 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 lessOverride: 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.
MILESMap Is a separate hierarchy (not a Collection).
"Sleep keeps, Wait waves"sleep keeps locks; wait releases them.
TUNATree types: no null, Unique, Navigable, sorted (Auto).

16. Quick Reference Tables

Access Modifiers

ModifierClassPackageSubclassWorld
private
default
protected
public

Collection Null Support

TypeNull Key/Element
HashMap / HashSetOne null allowed
TreeMap / TreeSet❌ NPE
ConcurrentHashMap❌ NPE
List.of / Set.of❌ NPE

Functional Interfaces

InterfaceMethodIn → Out
Supplier<T>get() → T
Consumer<T>acceptT → void
Function<T,R>applyT → R
Predicate<T>testT → boolean
UnaryOperator<T>applyT → T
BinaryOperator<T>apply(T,T) → T

Switch-Allowed Types

AllowedNot Allowed
byte short char int + wrapperslong float double boolean
String, enum(classic switch)

Big-O Quick Glance

Structuregetaddcontains
ArrayListO(1)O(1)*O(n)
LinkedListO(n)O(1)O(n)
HashMap/HashSetO(1)O(1)O(1)
TreeMap/TreeSetO(log n)O(log n)O(log n)

17. Top 100 Concepts to Remember

  1. JDK ⊃ JRE ⊃ JVM.
  2. javac compiles to bytecode; JVM runs it.
  3. java File.java runs source directly (Java 11+).
  4. One public type per file; file name matches it.
  5. Source order: package → import → type.
  6. main(String[] args) is the entry point.
  7. java.lang is auto-imported.
  8. Wildcard imports are not recursive.
  9. Local variables have no defaults.
  10. Fields default to 0/false/null.
  11. var is local-only, needs initializer.
  12. Access: private < default < protected < public.
  13. Init order: static → instance → constructor.
  14. Parent initializes before child.
  15. 8 primitive types exist.
  16. long=L, float=f suffixes.
  17. Underscores only between digits.
  18. Integer cache: -128..127 → == true.
  19. Unboxing null → NPE.
  20. No boxing + widening together.
  21. Widening auto; narrowing needs cast.
  22. Narrowing truncates and wraps.
  23. Compound assignment hides a cast.
  24. byte/short/char promote to int.
  25. 'A'+'B' = 131.
  26. 1/0 throws; 1.0/0 = Infinity.
  27. NaN == NaN is false.
  28. String is immutable and pooled.
  29. new String is a heap object.
  30. StringBuilder has no equals override.
  31. if requires boolean.
  32. Classic switch falls through.
  33. Switch rejects long/float/double/boolean.
  34. Switch expression must be exhaustive.
  35. Arrow switch has no fall-through.
  36. yield returns from a switch block.
  37. Pattern switch needs case null for null.
  38. Pattern dominance errors at compile time.
  39. Sealed enables exhaustive switch.
  40. while(false){} is a compile error.
  41. for-each variable is a copy.
  42. do-while needs trailing ;.
  43. Labels target outer loops.
  44. Single class inheritance only.
  45. Constructors aren't inherited.
  46. this()/super() must be first.
  47. Implicit super() is inserted.
  48. Param-only parent forces super(args).
  49. Overriding: same/covariant return.
  50. Overriding: same or wider access.
  51. Overriding: narrower/no checked exceptions.
  52. Overloading: compile-time binding.
  53. Return-type-only overload = error.
  54. Only instance methods are polymorphic.
  55. Fields and statics are hidden (reference type).
  56. Upcast is implicit; downcast explicit.
  57. Bad downcast → ClassCastException.
  58. null instanceof X is false.
  59. Override equals + hashCode together.
  60. abstract + final is illegal.
  61. final: class/method/variable rules.
  62. Records are implicitly final.
  63. Record accessor is x() not getX().
  64. Records can't extend classes.
  65. Compact constructor validates.
  66. Sealed subtypes: final/sealed/non-sealed.
  67. permits optional if same file.
  68. Record patterns deconstruct.
  69. instanceof String s binds a variable.
  70. Throwable → Error + Exception.
  71. Checked must catch or declare.
  72. Unchecked = RuntimeException/Error.
  73. Never catch Error.
  74. catch order: specific → general.
  75. Multi-catch types must be disjoint.
  76. finally overrides via return.
  77. try-with-resources closes in reverse.
  78. Close exceptions are suppressed.
  79. throw null → NPE.
  80. Map is not a Collection.
  81. TreeSet/TreeMap reject null keys.
  82. PECS: producer extends, consumer super.
  83. Can't add to <? extends T>.
  84. Type erasure removes generics at runtime.
  85. List.of is immutable.
  86. removeIf avoids ConcurrentModificationException.
  87. Streams are lazy and single-use.
  88. iterate/generate need limit.
  89. orElse always evaluates; orElseGet lazy.
  90. Optional.get() on empty throws.
  91. toMap duplicate keys need merge fn.
  92. start() spawns; run() doesn't.
  93. volatile = visibility only.
  94. wait/notify need synchronized.
  95. Deadlock = 4 conditions; fix lock order.
  96. Callable returns + throws; Runnable doesn't.
  97. Future.get() blocks.
  98. ConcurrentHashMap forbids nulls.
  99. Virtual threads: don't pool.
  100. 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

StrategyDetail
Read carefullyWatch for "compiles", "runtime exception", "no output".
Check imports & signaturesMany traps hide in missing imports or wrong main.
Scan for compile errors firstIf it doesn't compile, runtime answers are wrong.
Eliminate optionsRemove clearly wrong ones to improve odds.
Flag and move onDon't burn time; revisit flagged questions.
Trace code on scratch paperTrack variable values and init order.
Watch the clock~1.8 min/question; leave time to review.
Answer everythingNo penalty for guessing — never leave blanks.

Code-Reading Checklist (per question)

  1. Does it compile? (signatures, types, access, exceptions)
  2. Any unreachable code or uninitialized locals?
  3. Initialization order for output questions.
  4. Reference type vs object type for field/method/static.
  5. Autoboxing / Integer cache / String pool for ==.
  6. Checked exceptions caught or declared?
  7. 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.