SaveMyCert
Log in
5 of 5 free questions left today·for 30 a day
1Z0-831 quick-recall

1Z0-831 flashcards

Flip through 24 cards — one per 1Z0-831 topic — and self-test the key exam facts. Free, no account needed. These exams reward fast recognition, which is exactly what flashcards train.

1 / 24

Every 1Z0-831 flashcard, by exam domain

238 key facts across 10 domains — the full deck below, so you can scan it even without the interactive cards.

Handling Date, Time, Text, Numeric and Boolean Values

11% of the exam
  • A whole-number literal is an int and a decimal literal is a double unless it ends in L or f; a leading 0 means octal.
  • byte, short and char operands are promoted to int before arithmetic, so the result needs a cast to go back to the narrow type.
  • Without a cast, only a compile-time constant of type int or smaller that fits can be assigned to byte, short or char.
  • Compound assignment (+=, *=, ...) and ++/-- carry a hidden cast to the variable's type, so they compile where the long form does not and can overflow silently.
  • Integer casts keep the low-order bits; floating-to-integer casts truncate toward zero, saturate at the type's limits and turn NaN into 0.
  • Integer division truncates toward zero, % takes the dividend's sign, and integer division by zero throws while floating-point division gives Infinity or NaN.
  • int arithmetic wraps on overflow before any assignment to long; make the first operand long, or use Math.addExact and friends to get an exception.
  • && and || can skip their right operand; & and | always evaluate both; && binds tighter than ||.
  • Unboxing null throws NullPointerException, wrappers are immutable, and wrapper equals() is false for a different wrapper type.
  • Math.round returns long for a double and int for a float and breaks ties upward; floor and ceil return double.
  • String is immutable: methods return a new String, and an unassigned result is lost; StringBuilder methods mutate the builder and return this.
  • == on Strings tests identity. Literals, compile-time constant expressions (including final constant variables), text blocks and intern() results share the pooled object; runtime concatenation and new String() do not.
  • Ranges are start-inclusive, end-exclusive. substring needs 0 <= begin <= end <= length(); violations throw StringIndexOutOfBoundsException at run time.
  • + is evaluated left to right pair by pair: numbers before the first String are added, everything after is appended; char + int is an int, and null appends as "null".
  • strip() and isBlank() are Unicode-aware; trim() only removes characters up to U+0020; isEmpty() means length 0.
  • compareTo returns the first char difference or the length difference; uppercase letters sort before lowercase ones.
  • split() takes a regex and, with no limit, drops trailing empty Strings; format conversion mismatches fail at run time.
  • StringBuilder index checks use length(), not capacity; delete/replace clamp an end past the length, while setCharAt/deleteCharAt/charAt throw.
  • StringBuilder.equals() is identity; compare content with compareTo(), contentEquals() or toString().equals().
  • A text block starts on the line after """; the closing delimiter's position controls indentation and the trailing newline; \ joins lines and \s keeps a trailing space.
  • Every java.time object is immutable: plus, minus and with return a new object, and an unassigned result is lost.
  • of() factories validate at run time: months are 1-based, hours 0–23, and 29 February needs a leap year — otherwise DateTimeException.
  • plusMonths, withMonth and withYear clamp to the month's last valid day; withDayOfMonth throws for a day the month lacks.
  • LocalTime arithmetic wraps silently past midnight, but LocalTime differences assume the same day and can be negative.
  • Duration prints PTnHnMnS with no day part (ofDays(3) is PT72H); Period prints PnYnMnD, turns weeks into days, and is only normalized (months into years) when you call normalized().
  • Period.ofX methods are static, so chaining them keeps only the last call; use Period.of(y, m, d) or the withX/plusX instance methods.
  • between() and until() count complete units only; toTotalMonths() folds years into months while getMonths() returns just the component.
  • Unsupported units compile but throw UnsupportedTemporalTypeException at run time: no time units on LocalDate, no date units on LocalTime, nothing beyond DAYS on Instant.
  • withZoneSameInstant keeps the moment and changes the clock; withZoneSameLocal keeps the clock and changes the moment; equals compares zone and local value, isEqual compares the instant.
  • In a DST gap the time moves forward by the gap; in an overlap the earlier offset wins; plusDays and Period keep the wall clock while plusHours and any Duration add elapsed time.

Implementing Program Flow Control Using Decision and Looping Constructs

8% of the exam
  • Without braces, an else binds to the nearest unmatched if, whatever the indentation, and only one statement belongs to each branch.
  • Conditions must be boolean or Boolean; assigning an int in a condition does not compile, while assigning a boolean compiles and tests the assigned value.
  • Colon labels fall through every following group, including default, until a break; default's position never changes which label matches.
  • Arrow labels never fall through, take one expression statement, block or throw, and cannot be mixed with colon labels in one switch.
  • A switch expression must yield or throw on every path and cannot be left with return, break or continue.
  • A switch expression is exhaustive with a default, an unguarded pattern of the selector's own type, every enum constant, or every permitted subtype of a sealed type.
  • Constant labels need compile-time constants that fit the selector type and never repeat; long, float, double and boolean selectors do not compile in Java 25.
  • A null selector throws NullPointerException unless the switch has case null; default alone does not match null.
  • Pattern labels are tried top to bottom; an unguarded pattern before a subtype or constant label of its type is a dominance error.
  • Inside a switch in a loop, break leaves only the switch and continue goes to the loop's next iteration; continue label needs a loop label.

Applying Object-Oriented Principles in Java Programs

18% of the exam
  • A variable holds a reference, not an object; only new (or an array creation) creates objects, and unassigned reference fields are null.
  • Mutating through an alias changes the shared object; reassigning a variable changes only that variable.
  • Java passes references by value: a method can mutate the caller's object but can never reseat the caller's variable.
  • Inner class objects need an enclosing instance: outerRef.new Inner(); static nested classes use new Outer.Nested().
  • Member and local records, enums and interfaces are implicitly static and cannot use outer instance fields or captured locals.
  • Outer.this.name reaches a shadowed field of an enclosing instance; this in an anonymous class is the anonymous object, in a lambda the enclosing one.
  • Local and anonymous classes (and lambdas) may only capture final or effectively final locals.
  • An object is eligible once no live thread can reach it from a root; unreachable cycles are eligible too.
  • System.gc() is only a request — eligibility is guaranteed by your references, reclamation is up to the JVM.
  • A reachable inner object that uses its outer object keeps that outer object alive; prefer static nested classes when the link is not needed.
  • A static field is one variable per class shared by every instance; an instance field is a fresh copy in each object, and static code cannot use one without naming an object.
  • The default no-argument constructor exists only when a class declares no constructors; a member with a return type, even void, is a method, not a constructor.
  • A constructor without an explicit this(...) or super(...) gets an implicit super(), which needs an accessible no-argument superclass constructor.
  • this(...) chains complete inside-out; only the constructor that calls super(...) runs the instance initializers, once per object.
  • Java 25 prologues may use parameters, locals, static methods and static fields, throw, and assign the class's own fields without initializers — but never read instance fields, call instance methods, use this or return.
  • Construction order: prologues run from the subclass up; then, from the top class down, each class runs its field initializers and instance blocks in source order followed by its constructor body. Static parts run once per class, parent first, on first active use.
  • A superclass constructor calling an overridden method sees subclass fields at their defaults unless the subclass assigned them in its prologue.
  • Reading a constant variable (final primitive or String with a constant initializer) is inlined and does not initialize the class; a final Integer is not a constant.
  • A blank final field must be assigned exactly once on every constructor path; a checked exception from an instance initializer must be caught there or declared by every constructor.
  • Records generate private final fields, a canonical constructor with the record's access level, public name-matched accessors and a component-listing toString (brackets in current JDKs); compact constructors reassign parameters, non-canonical ones must delegate, and records allow no extra instance fields or instance initializers.
  • An overload must differ in its parameter types or their order; return type, parameter names, static, access modifiers and throws do not make a new signature.
  • Overload resolution runs three phases in order — widening, then boxing/unboxing, then varargs — and stops at the first phase with a candidate.
  • Method arguments are never narrowed: an int literal such as 300 does not reach a short parameter, 2.5 does not reach float, and char and short never convert into each other.
  • Among widening candidates the nearest type wins: int before long before float before double, and long widens to float; a wrapper reaches Number or Object in phase 1, before unboxing.
  • Box then widen is legal (int to Integer to Number); widen then box is not (int never becomes Long or Double).
  • null goes to the most specific reference overload; two unrelated applicable types, such as Integer and String, make the call ambiguous, and adding Object does not break the tie.
  • Type... must be the single, last parameter and is an array: it cannot coexist with a Type[] overload, receives an empty array for no arguments, and receives the caller's own array when one is passed.
  • An int[] passed to Object... is wrapped as one element, while a String[] is passed as the array itself.
  • Overloads are chosen from declared types at compile time; a subclass method with a different parameter type is an overload, not an override, so a superclass reference never sees it.
  • A local is in scope from its declaration to the end of its block; it cannot be redeclared in an inner block while still in scope, but a field can be shadowed.
  • A colon-style switch block is one scope, so a local declared under one case is visible (but not initialized) under later cases; arrow cases each have their own block.
  • Locals have no default value: the compiler rejects reads that are not definitely assigned, and it only trusts constant expressions and statement structure.
  • Pattern variables are flow-scoped: in scope wherever the match is known to have succeeded, including after an if whose failure branch cannot complete normally.
  • Lambda parameters live in the enclosing scope and cannot reuse a local's name; an anonymous class method's parameter can shadow it.
  • private is checked per class: code in a class can read the private fields of any instance of that class, but not those of another class in the same file.
  • final is shallow — copy mutable inputs and outputs; Collections.unmodifiableList is a view of the source, List.copyOf is an unmodifiable copy.
  • Blank final fields must be assigned exactly once, in an initializer or in every constructor; in a record, reassign the compact constructor’s parameter to store a copy.
  • var infers the initializer's exact static type — ArrayList<Object> from an empty diamond, the anonymous class itself — and is rejected for fields, parameters, null, bare array initializers and compound declarations.
  • _ declares an unnamed local, for, resource, catch, lambda or pattern variable; it can repeat in one scope, can never be read, and its initializer still runs.
  • The reference type decides what compiles — callable members, overload choice and checked exceptions; the object type decides which overriding instance method body runs.
  • An override needs the same signature, the same or wider access, the same or a covariant return type, and no new or broader checked exceptions; different parameter types make an overload.
  • Use @Override on every intended override — it turns an accidental overload into a compile error.
  • private methods are not inherited, final methods cannot be overridden, static methods are hidden, and a method cannot switch between static and instance.
  • Fields are hidden, never overridden: field access resolves by reference type, and an inherited method reads its own class's field.
  • A cast compiles unless no object could satisfy it (unrelated classes, or a final class to an interface it lacks); otherwise a wrong object throws ClassCastException at runtime.
  • Every constructor runs a superclass constructor first; with no explicit call the compiler inserts super(), which fails if the superclass has no no-arg constructor.
  • An overridable method called from a superclass constructor runs the subclass override before subclass fields are initialized — unless Java 25's prologue assigned them before super().
  • Permitted subtypes of a sealed type must be final, sealed or non-sealed; records are implicitly final, extend Record and may implement interfaces.
  • equals must be overridden as equals(Object), together with a consistent hashCode(); an equals(Coord) overload is ignored by collections.
  • Interface abstract methods are implicitly public abstract, so the implementing method must be declared public; a blank modifier in a class means package access.
  • An abstract class can implement an interface partially; the first concrete subclass must supply every remaining abstract method.
  • Interface fields are public static final constants: they must be initialized, are inherited by implementers, are shared by everyone, and can never be assigned, though a final array or list can still change its contents.
  • Interfaces cannot declare protected members, blank fields, final or synchronized methods, or default versions of equals, hashCode and toString.
  • Call an overridden default with InterfaceName.super.method(), and only for a direct superinterface; plain super refers to the superclass.
  • Conflict rules in order: a class method wins (even an abstract one, which then must be implemented), then the more specific interface wins (even when it re-abstracts), otherwise the class must override.
  • Static interface methods are not inherited by classes or sub-interfaces: call them only as InterfaceName.method(); a same-signature static method in a class is unrelated.
  • Private interface methods are helpers for code inside the interface; static interface methods can use only private static helpers.
  • A functional interface has exactly one abstract method after inheritance; defaults, statics, privates and public Object methods do not count, but clone() does.
  • @FunctionalInterface only makes the compiler check the count; removing it never turns a two-method interface into a lambda target.
  • Constants come first, then a semicolon, then members; every constant's argument list must match a declared constructor.
  • Enums implicitly extend Enum: they can implement interfaces but never extend a class, and no class can extend them; local enums are legal.
  • Enum constructors are private or have no modifier; they can be overloaded and chained with this(...), but super(...) and new are compile errors.
  • All constants are constructed once, in declaration order, at the enum's first use, before any static block or later static field initializer.
  • A constructor cannot reference the enum's static fields (other constants included) except constant variables; indirect access compiles but can be wiped by a later initializer, and values() during construction throws.
  • values() returns a fresh copy each call; valueOf matches name() exactly and case-sensitively, throwing IllegalArgumentException for unknown names.
  • name(), ordinal(), equals() and compareTo() are final; toString() can be overridden, which breaks the valueOf(toString()) round trip.
  • == and equals compare identity; compareTo and sorting follow declaration order.
  • A constant body is an anonymous subclass: it can override methods and implement abstract ones, getClass() returns the subclass, and methods declared only in the body are not callable from outside.
  • Switch expressions over enums must cover every constant or have default; plain switch statements need not, but a variable assigned only in a statement's arms needs a default to be definitely assigned, and default never matches null, only case null does.

Implementing Exception Handling in Java Applications

8% of the exam
  • Unchecked means RuntimeException or Error (and subclasses); every other Throwable, including Exception and Throwable itself, is checked and must be caught or declared.
  • catch (Exception e) never catches an Error; finally still runs for one, and a failing static initializer surfaces as ExceptionInInitializerError with the original as its cause.
  • Catches are tried top to bottom: a superclass before its subclass fails to compile, and catching a checked exception the try block cannot throw fails too.
  • An exception thrown inside a catch block goes outward through finally, never to a sibling catch.
  • Multi-catch alternatives must be unrelated, the parameter is implicitly final, and its type is the alternatives' common supertype.
  • A return value is fixed before finally runs; a return, continue, break or throw in finally overrides it or any pending exception, and plain try/finally suppresses nothing.
  • Try-with-resources closes right to left, before its own catch and finally run; resource variables are final and scoped to the try block, and null resources are skipped.
  • The first exception thrown in try-with-resources is primary; later close() failures are suppressed onto it, and a failed initializer closes only the resources before it.
  • A custom exception's toString() is ClassName: message, getMessage() is null when no message was passed, and super(cause) alone copies cause.toString() into the message.

Using Arrays and Collections to Store and Retrieve Data

8% of the exam
  • New array elements default to 0, 0.0, false, '\u0000' or null; the last index is length - 1; int[] g[] is an int[][]; only the first dimension of new int[3][] is required, and its unassigned rows are null.
  • Arrays don't override equals or toString — use Arrays.equals, Arrays.toString and Arrays.compare/mismatch; clone() of a 2D array shares the rows.
  • Arrays.binarySearch needs a sorted array and returns -(insertion point) - 1 for a missing key.
  • Arrays.asList is fixed-size and writes through to its array (set and sort work); List.of/List.copyOf are unmodifiable (sort throws too) and reject null; unmodifiableList and subList are live views.
  • On a List<Integer>, remove(1) removes index 1; set returns the replaced element; remove inside for-each usually throws ConcurrentModificationException — use removeIf or Iterator.remove.
  • thenComparing only breaks ties, and reversed() reverses the whole comparator chain to its left.
  • HashSet/HashMap need consistent equals(Object) and hashCode; TreeSet uses its comparator for add, contains and remove, keeping the first "equal" element; Set.equals compares elements only.
  • put returns the old value; getOrDefault ignores null values but putIfAbsent overwrites them; a null result from merge or compute* removes the mapping.
  • Deque: push/pop/peek work at the head, offer/add at the tail; poll/peek return null on empty, pop/remove()/element throw, remove(Object) just returns false; ArrayDeque rejects null.
  • Sequenced collections add getFirst/getLast/addFirst/addLast/reversed(); reversed() writes through, and sorted sets/maps and unmodifiable views throw UnsupportedOperationException on positional inserts.

Processing Data Using Streams and Lambda Expressions

9% of the exam
  • Nothing runs without a terminal operation; elements then pass through all stages one at a time, and short-circuiting operations stop early.
  • A stream is single-use: a second operation on the same stream object throws IllegalStateException at that call, never a compile error.
  • range excludes its end, rangeClosed includes it; three-argument iterate checks its predicate before every element; iterate and generate without a bound never end.
  • Slicing operations apply in the order written; takeWhile ends at the first failure, dropWhile stops testing at the first failure.
  • On an empty stream allMatch and noneMatch are true and anyMatch is false; findFirst returns Optional.empty.
  • Only primitive streams have sum and average; max, min and average return OptionalInt/OptionalDouble, while sum and count return a primitive 0 when empty.
  • sorted() on non-Comparable elements compiles and throws ClassCastException; reversed() reverses every key before it, and a chained comparing(lambda) loses its target type.
  • IntFunction takes an int, ToIntFunction returns one; methods returning int, long or double are named applyAsInt, applyAsLong, applyAsDouble, while every predicate uses test and BooleanSupplier uses getAsBoolean.
  • Captured locals must be effectively final, but the objects they reference may be mutated; lambda parameters cannot reuse an in-scope local's name.
  • compose runs its argument first, andThen runs it last, and composing a UnaryOperator yields a Function.
  • reduce(identity, op) returns T, reduce(op) returns Optional<T>, and reduce(identity, accumulator, combiner) returns a different type U; only the three-argument form can change type, and Optional.stream() turns a result into a zero- or one-element stream.
  • A reduce accumulator that produces null as the final result throws NullPointerException; Optional.empty means only that the stream was empty.
  • Parallel reductions need a true identity, an associative operation and a combiner compatible with the accumulator; an identity is the value that never changes the result (0 for sum, 1 for product, Integer.MAX_VALUE for min, Integer.MIN_VALUE for max).
  • collect(supplier, accumulator, combiner) and Collectors.toCollection are thread-safe because each chunk gets its own container; the combiner must merge its second argument into its first.
  • Empty streams: sum is 0, average is an empty OptionalDouble, max/min are empty Optionals, and summaryStatistics reports count 0 and average 0.0 without throwing.
  • joining needs CharSequence elements and always adds its prefix and suffix; toMap throws IllegalStateException on a duplicate key unless given a merge function (existing value first).
  • Downstream collectors fix the value type: counting is Long, summingInt is Integer, averaging is Double; groupingBy rejects a null key with NullPointerException.
  • partitioningBy always holds both false and true keys, an empty side holding the downstream's result for zero elements; groupingBy only creates keys that occur.
  • Stream.concat is lazy, keeps argument order, needs two streams of the same kind and fails with IllegalStateException on a consumed stream; flatMap treats a null mapped stream as empty.
  • windowFixed leaves a short last window, windowSliding gives one short window only when the stream is shorter than n, fold emits one value, scan emits running values, and mapConcurrent keeps encounter order.

Packaging and Deploying Java Code

9% of the exam
  • Cross-module access needs three things: the module reads the other module, the package is exported to it, and the type and member are public.
  • exports names exactly one package; subpackages are unrelated, wildcards do not exist, and a duplicate export of the same package is a compile error.
  • exports p to m1, m2 limits access to the named modules; a missing target only warns, and readability through requires transitive never widens it.
  • Readability is not transitive unless declared: requires transitive gives implied readability and belongs wherever your API exposes another module's types.
  • requires static is mandatory at compile time and optional at run time; the module is resolved only if something else requires it or --add-modules adds it.
  • Cyclic requires fail to compile; a package in two modules (even concealed) stops the boot layer from initializing.
  • exports gives public access; opens (or open module) is needed for setAccessible on private members, otherwise InaccessibleObjectException; opening a missing package warns at compile time but fails at launch; open modules cannot contain opens.
  • Consumers declare uses (or ServiceLoader throws ServiceConfigurationError), providers declare provides S with Impl, and service binding pulls providers in without any requires; uses and provides never create readability.
  • A provider is public and either has a public static provider() method, which wins, or is a concrete subtype of the service with a public no-argument constructor.
  • import module M imports the packages M (and its transitive dependencies) export to you, grants no readability, and loses to on-demand and single-type imports; compact source files import module java.base implicitly.
  • A compact source file is an implicitly declared final class in the unnamed package: default constructor only, no package declaration, a required main method, and no code can refer to it by name.
  • Compact source files import all of java.base automatically; java.lang.IO is usable from every class without an import, but an ordinary class must still import java.util.List and friends.
  • The launcher prefers a non-private void main(String[]) (declared or inherited) over void main(); private methods are never candidates; an instance main needs a non-private no-arg constructor, which runs (with field initialisers) first.
  • java File.java compiles in memory, writes no class files, launches the first top-level class in the file, and passes everything after the file name to main; launcher options go before it.
  • Multi-file source programs compile other source files on demand from the root implied by the package; unreferenced files are not compiled; libraries go in --class-path before the file name.
  • javac -d places classes by package; java -cp needs the package root plus the fully qualified class name, or you get ClassNotFoundException or a wrong-name NoClassDefFoundError.
  • java -jar needs a Main-Class manifest attribute and ignores -cp entirely; dependencies come from the manifest Class-Path.
  • A modular JAR is a named module only on the module path; -m module needs ModuleMainClass (jar --main-class), -m module/class always works, and the first module-path entry with a given name wins.
  • jlink links the root modules plus their transitive requires into an image whose --output must not exist; it refuses automatic modules.
  • Named modules cannot read the unnamed module; automatic modules export and open everything and read everything, which is why they bridge migration; split packages on the module path fail resolution.

Implementing Multithreading for Concurrent Code Execution

11% of the exam
  • start() runs the task on a new thread; calling run() runs it on the current thread. A Thread can be started only once: a second start() throws IllegalThreadStateException.
  • Virtual threads are always daemons, have a fixed priority of 5 and an empty default name, support ThreadLocal, and should be created per task, never pooled; setDaemon(false) throws IllegalArgumentException.
  • join() leaves the caller WAITING; sleep(ms) and join(ms) give TIMED_WAITING; BLOCKED means waiting for a monitor. join(ms) just returns when time runs out.
  • Throwing InterruptedException clears the interrupt flag, and a pending interrupt makes sleep throw at once. Thread.interrupted() clears the flag; isInterrupted() does not.
  • A value-returning lambda is a Callable (checked exceptions allowed); a void body is a Runnable. Future.get() returns null for a Runnable and throws ExecutionException, with the task's exception as cause, for a failed task.
  • invokeAll returns futures in task-list order; invokeAny returns one successful result and throws ExecutionException only if every task fails.
  • After shutdown, new tasks are rejected with RejectedExecutionException; shutdownNow attempts to stop running tasks (by interrupting them) and returns the queued ones; close() shuts down and waits for every task.
  • scheduleAtFixedRate measures from start to start, scheduleWithFixedDelay from end to start; a periodic run that throws cancels the rest and makes get() throw ExecutionException.
  • In CompletableFuture, only exceptionally and handle recover from a failure; get() wraps it in ExecutionException and join() in CompletionException.
  • ScopedValue.where(...).run/call binds an immutable value for that call only; get() on an unbound value throws NoSuchElementException, and new threads do not inherit the binding.
  • count++ and x = x + 1 are read-modify-write: without a shared lock or an atomic class, concurrent updates are lost and the result can change from run to run.
  • A synchronized instance method locks this, a static synchronized method locks the Class object, a block locks the object its expression evaluates to — two calls exclude each other only on the same object.
  • Lock a private final dedicated object; locking a reassigned field, a boxed Integer, new Object() or Thread.currentThread() protects nothing.
  • Intrinsic locks and ReentrantLock are reentrant (hold counts); wait() releases every hold and restores them when the thread wakes.
  • volatile gives visibility and happens-before ordering for single reads and writes, never atomicity of compound actions.
  • getAndX returns the old value, xAndGet the new one; compareAndSet stores only when the current value equals the expected one and returns whether it did.
  • Always lock() then try { … } finally { unlock(); }; unlock() by a non-owner throws IllegalMonitorStateException, and a Lock is never released automatically.
  • lock() ignores interrupts, tryLock() returns at once, tryLock(long, TimeUnit) and lockInterruptibly() throw InterruptedException; there is no tryLock(long) or tryLock(Duration).
  • Read locks are shared and the write lock is exclusive; a writer may downgrade to a read lock, a reader cannot upgrade.
  • wait/notify and Condition need the lock held and a while-loop guard; a latch never goes below zero, a barrier resets each trip and breaks on timeout, and semaphore permits have no owner, and release() can raise the count above its initial value.
  • Synchronized is not concurrent: Vector and Collections.synchronizedX make single calls safe, but their iterators still fail fast; java.util.concurrent iterators never throw ConcurrentModificationException.
  • Iterate or check-then-act on a synchronized wrapper inside synchronized (wrapper); the wrapper's own forEach is already locked, its stream is not.
  • ConcurrentHashMap and the other concurrent maps reject null keys and values; a null returned from a compute or merge function means "no mapping" and removes or skips.
  • Use merge, compute or computeIfAbsent for read-modify-write on a ConcurrentHashMap; get-then-put loses updates.
  • ConcurrentSkipListMap/Set are the sorted, thread-safe TreeMap/TreeSet; ConcurrentHashMap.newKeySet() is the unordered thread-safe set.
  • CopyOnWriteArrayList iterators are snapshots: writes during a loop are allowed and invisible to it, and Iterator.remove throws UnsupportedOperationException.
  • On a full or empty BlockingQueue, add/remove throw, offer/poll return false/null, put/take wait — and put, take and the timed versions throw the checked InterruptedException.
  • The last parallel() or sequential() call sets the mode for the whole pipeline.
  • Ordered parallel streams keep encounter order in results (toList, joining, findFirst, skip, limit, distinct, sorted), never in side effects; forEach is unordered, forEachOrdered is not.
  • Collect parallel results with a collector; toConcurrentMap needs a merge function for repeated keys, and groupingByConcurrent does not keep order within groups.

Performing Input and Output Operations Using the Java I/O API

11% of the exam
  • Reader/Writer subclasses are character streams; InputStream/OutputStream subclasses are byte streams — PrintStream prints text but is a byte stream.
  • read() returns 0–255 (or a char) and -1 only at end of stream; read(buf) returns a count and leaves the rest of the array untouched.
  • readLine() drops the terminator, returns "" for a blank line and null at end of stream; a trailing terminator adds no empty line.
  • Decorators wrap only their own family; InputStreamReader and OutputStreamWriter (or PrintWriter over an OutputStream) bridge bytes and characters.
  • Closing a wrapper flushes and closes the inner stream; a closed file or console stream then throws IOException on use, in-memory streams ignore close(), and a second close() is harmless.
  • Opening a file for writing truncates it unless the opening constructor is given append = true; PrintWriter's boolean is autoflush, not append.
  • Buffered output reaches its destination only on flush(), close() or a full buffer; PrintWriter autoflush covers println, printf and format only.
  • PrintStream and PrintWriter swallow IOException (check checkError()), including in flush() and close(), except PrintStream.write(byte[]); most other java.io methods, close() included, declare it.
  • DataInputStream reads big-endian bytes back in the order written and throws EOFException at the end; bulk reads return empty arrays instead.
  • System.console() can be null; Console.readPassword returns char[], and java.lang.IO offers only print, println and readln.
  • Serializable is checked at run time: writing an object graph that reaches a non-serializable value throws NotSerializableException; null fields and static fields are never a problem.
  • readObject returns Object, declares IOException and ClassNotFoundException, and signals the end of the stream with EOFException, never null.
  • transient fields come back as 0, false or null because no initializer or constructor of a serializable class runs; only the first non-serializable superclass's no-arg constructor runs, and it must be accessible.
  • Static fields are not saved: after reading they show the class's current value in the reading JVM.
  • serialVersionUID must be a static final long with that exact name; with matching UIDs, added fields read as defaults and removed fields are ignored.
  • Custom writeObject/readObject must be private and non-static, should call defaultWriteObject/defaultReadObject first (omitting them is not detected, but non-transient fields are then not saved), and must read extra data in write order.
  • readResolve (an instance method returning Object) keeps singletons single; writeReplace plus a proxy's readResolve forms the serialization-proxy pattern.
  • Records are rebuilt through the canonical constructor and ignore readObject/writeObject; enums serialize by name and stay ==; Externalizable needs a public no-arg constructor and saves only what writeExternal writes.
  • Writing the same object twice on one stream writes a back-reference; use reset() or writeUnshared() to write its new state.
  • An ObjectInputFilter pattern is matched left to right, first match wins, unmatched classes are undecided, and a rejection throws InvalidClassException; set it before the first read.
  • Creating or manipulating a Path never touches the disk; only Files methods and toRealPath do.
  • The root is not a name element: getNameCount, getName and subpath count only the names after it, and subpath is zero-based, end-exclusive and relative.
  • getParent, getRoot and getFileName return null when the component is missing; out-of-range indexes or an empty range for getName or subpath throw IllegalArgumentException.
  • resolve appends a relative argument, returns an absolute argument as is, and never normalizes; resolveSibling resolves against the parent.
  • relativize climbs to the common ancestor with .. and throws IllegalArgumentException when one path is absolute and the other relative.
  • Paths are immutable: discard the result of normalize or resolve and the original is unchanged.
  • startsWith, endsWith and equals compare whole name elements and roots, not characters.
  • createFile and createDirectory need the parent and refuse existing targets; createDirectories builds parents and is idempotent for directories.
  • copy and move take the full target path, need REPLACE_EXISTING to overwrite, and never act recursively; delete fails on a non-empty directory, deleteIfExists returns false for a missing one.
  • Passing any open option stops CREATE and TRUNCATE_EXISTING being implied (WRITE always is); Files.lines, list, walk and find are lazy and must be closed.

Developing Applications with Localization Support

7% of the exam
  • Locale.of never validates, forLanguageTag never throws for an ill-formed tag ("de_CH" gives Locale.ROOT), and Locale.Builder throws IllformedLocaleException; toString uses underscores, toLanguageTag hyphens.
  • Locale.setDefault(loc) resets the general default and both categories; a category call changes only FORMAT or DISPLAY. Formatters read FORMAT, getDisplay… names read DISPLAY, getBundle's fallback reads the general default.
  • getBundle searches the requested locale (most specific first), then the default locale, then the base bundle; any partial match on the requested locale beats the default. A Locale.ROOT request takes the base bundle when it exists and tries the default only when it does not.
  • Missing keys resolve up the parent chain (es_MX → es → base); the default locale's files and sibling locales are never parents. getLocale() reports the bundle actually loaded.
  • MissingResourceException is unchecked and comes from getBundle (no bundle) or getString/getObject (no key anywhere in the chain).
  • A ListResourceBundle class beats a same-named properties file; property values are Strings, and getString on a non-String value throws ClassCastException.
  • In MessageFormat a lone apostrophe starts literal text (use two), unmatched placeholders print as {n}, {0,date} cannot format a LocalDate, and parse returns an Object[] or throws the checked ParseException.
  • NumberFormat and DecimalFormat round HALF_EVEN (4.5 → 4, 5.5 → 6); java.util.Formatter (String.format, formatted, printf) rounds HALF_UP.
  • NumberFormat.parse reads a leading number, returns Long or Double and throws the checked ParseException; java.time parsing throws the unchecked DateTimeParseException.
  • Pattern formatters resolve SMART (April 31 → April 30), LocalDate.parse is STRICT, and STRICT needs uuuu; LONG/FULL time styles need a zone.

Keep studying 1Z0-831

1Z0-831 flashcards: your questions

Yes — the whole 1Z0-831 deck is free and needs no account, as is every 1Z0-831 revision lesson. Create a free account to save progress and drill practice questions; full-length mock exams are a one-time unlock per certification.

Source

Exam structure, domain weights and scoring on this page come from the official 1Z0-831 exam guide.