Java SE 8 Programmer II key terms
Java SE 8 Programmer II · Get comfortable with the vocabulary.
- Encapsulation
- Related: Immutability, Polymorphism
Bundling instance fields with the methods that operate on them and hiding the fields behind private access, exposing behavior through public methods. It lets a class enforce its own invariants and change internal representation without breaking callers.
- Immutability
- Related: Encapsulation, Defensive Copying
A design property where an object's state cannot change after construction, achieved with final fields, no setters, and defensive copying. Immutable objects are inherently thread-safe and safe to share across threads and collections.
- Defensive Copying
- Related: Immutability
Making a private copy of a mutable object received or returned by a method so callers cannot modify internal state through a retained reference. Commonly applied to arrays, Date, and collection constructor parameters.
- Polymorphism
- Related: Overriding, Abstract Class
The ability to treat objects of different subclasses through a common supertype reference, with the actual method executed chosen at runtime by dynamic dispatch. Enables extensible code that depends on abstractions rather than concrete classes.
- Overriding
- Related: Polymorphism, Covariant Return Type
Redefining an inherited instance method in a subclass with a compatible signature, return type, and no more restrictive access. The override is selected at runtime; annotations and access rules catch many mistakes at compile time.
- Covariant Return Type
- Related: Overriding
Allowing an overriding method to declare a return type that is a subtype of the overridden method's return type. Legal since Java 5 and useful for fluent builders and clone-style methods.
- Abstract Class
- Related: Interface Default Method, Polymorphism
A class declared abstract that cannot be instantiated and may declare abstract methods subclasses must implement. It supports shared state and partial implementation, unlike an interface's pre-Java 8 restrictions.
- Interface Default Method
- Related: Abstract Class, Functional Interface
A method in an interface declared with the default keyword that supplies an implementation classes inherit unless they override it. It enables adding methods to published interfaces without breaking existing implementors.
- Static Interface Method
- Related: Interface Default Method
A method declared static inside an interface, invoked only through the interface name and not inherited by implementing classes. Useful for utility factories tied to the interface's type.
- Functional Interface
- Related: Lambda Expression, Method Reference
An interface with exactly one abstract method, optionally annotated @FunctionalInterface. Lambdas and method references can implement it, and the compiler infers the target type from context.
- Lambda Expression
- Related: Functional Interface, Effectively Final
A concise anonymous implementation of a functional interface, written as parameters, an arrow, and a body. It captures effectively final local variables and compiles to an invokedynamic call site rather than a separate class file.
- Effectively Final
- Related: Lambda Expression
A local variable or parameter whose value is never reassigned after initialization, making it eligible for capture by a lambda or local class. The final keyword is not required.
- Method Reference
- Related: Functional Interface, Lambda Expression
A shorthand lambda of the form Type::method, Class::instanceMethod, object::method, or Class::new that reuses an existing method as a functional interface implementation.
- Type Erasure
- Related: Bounded Type Parameter, Wildcard
The compiler's process of removing generic type parameters, inserting casts, and generating bridge methods so generic code runs on raw types at runtime. Explains why instanceof List and new T() are illegal.
- Bounded Type Parameter
- Related: Type Erasure, Wildcard
A generic declaration restricting a type argument, as in <T extends Comparable>, granting access to the bound's members. Multiple bounds use & with at most one class, listed first.
- Wildcard
- Related: Bounded Type Parameter, Type Erasure
The ? placeholder in generic type arguments, optionally bounded as ? extends T for reading or ? super T for writing. Follows the PECS rule: producer extends, consumer super.
- Comparable
- Related: Comparator, TreeMap
An interface whose single compareTo method defines a class's natural ordering, used by sorted collections and Collections.sort. Contract requires consistency with equals for correct behavior in sorted sets and maps.
- Comparator
- Related: Comparable
A separate comparison object supplying an ordering through compare, allowing multiple orderings per type and use with sort, TreeSet, and TreeMap. Java 8 added default methods like comparing, reversed, and thenComparing.
- HashMap
- Related: HashSet, TreeMap
A hash-table-based Map implementation offering constant-time average get and put, no ordering guarantee, one null key, and null values. Keys must implement consistent hashCode and equals.
- TreeMap
- Related: Comparator, Comparable
A sorted Map backed by a red-black tree, ordered by natural ordering or a supplied Comparator, with O(log n) operations. It does not permit null keys when using natural ordering.
- HashSet
- Related: HashMap
A Set implementation backed by a HashMap that stores unique elements with no ordering guarantee. Uniqueness depends on the elements' hashCode and equals contracts.
- Stream Pipeline
- Related: Intermediate Operation, Terminal Operation
A sequence of a source, zero or more lazy intermediate operations, and one terminal operation that triggers execution. A stream can be consumed only once and does not store data.
- Intermediate Operation
- Related: Stream Pipeline, Terminal Operation
A stream operation such as filter, map, or sorted that returns a new stream and is lazy, doing no work until a terminal operation runs. Stateless operations process elements independently.
- Terminal Operation
- Related: Stream Pipeline, Collector
A stream operation such as collect, forEach, reduce, or count that consumes the pipeline and produces a result or side effect. After it runs, the stream is exhausted.
- Collector
- Related: Terminal Operation, Optional
An object passed to Stream.collect describing how to accumulate elements into a result, optionally with a supplier, accumulator, combiner, and finisher. Collectors offers ready-made implementations such as toList and groupingBy.
- Optional
- Related: Collector
A container that either holds one non-null value or is empty, used as a return type to signal possible absence without null. Provides map, flatMap, filter, orElse, and orElseThrow.
- Checked Exception
- Related: Unchecked Exception, try-with-resources
An exception that is a subclass of Exception but not RuntimeException, which the compiler requires to be caught or declared with throws. Used for recoverable conditions the caller should handle.
- Unchecked Exception
- Related: Checked Exception
A RuntimeException or Error subclass that the compiler does not require to be caught or declared. Usually signals programming errors such as null dereference, bad cast, or illegal argument.
- try-with-resources
- Related: Checked Exception, AutoCloseable
A try statement that declares one or more AutoCloseable resources and closes them automatically in reverse declaration order, even when exceptions occur. Suppressed exceptions are attached to the primary exception.
- AutoCloseable
- Related: try-with-resources
An interface declaring a single close method, implemented by resources usable in try-with-resources. Closeable refines it with an IOException-typed close method.
- Assertion
- Related: Unchecked Exception
A boolean check written with the assert keyword, enabled only when the JVM runs with -ea and disabled by default. Intended for validating internal invariants during development, never for public argument checking.
- Serialization
- Related: transient
Converting an object graph to a byte stream via ObjectOutputStream and back with ObjectInputStream. Requires Serializable, uses serialVersionUID for version compatibility, and skips transient fields.
- transient
- Related: Serialization
A field modifier excluding that field from default serialization, so it is restored as its default value on deserialization. Often combined with custom readObject and writeObject methods.
- Console
- Related: BufferedReader
A java.io object obtained from System.console providing character-based input and password reading without echo. It returns null when no interactive console is attached, such as in many IDE or CI runs.
- BufferedReader
- Related: Console
A java.io reader that buffers characters to reduce I/O calls, offering readLine for line-based text input. Usually wrapped around FileReader or InputStreamReader.
- Thread Deadlock
- Related: synchronized, ExecutorService
A situation where two or more threads each hold a lock the others need and all wait forever. Prevented by consistent lock ordering, timeouts, or avoiding nested lock acquisition.
- synchronized
- Related: Thread Deadlock, Atomic Variable
A keyword providing mutual exclusion on an object's monitor for a method or block, also establishing happens-before visibility. It is reentrant, so a thread can reacquire a monitor it already holds.
- Atomic Variable
- Related: synchronized
A class such as AtomicInteger supporting lock-free thread-safe updates through compare-and-set operations. Preferred over synchronization for simple counters and references under contention.
- ExecutorService
- Related: Thread Deadlock, ForkJoinPool
A thread-management abstraction that accepts tasks and runs them on a pool, decoupling submission from execution. Shut down with shutdown or shutdownNow and typically awaited with awaitTermination.
- ForkJoinPool
- Related: ExecutorService, Stream Pipeline
An executor using work-stealing to run recursive divide-and-conquer tasks efficiently, backing parallel streams. Tasks extend RecursiveTask for results or RecursiveAction for side effects.
- PreparedStatement
- Related: ResultSet, CallableStatement
A precompiled SQL statement using parameter placeholders, set with typed setters such as setInt and setString. It improves performance on reuse and prevents SQL injection.
- ResultSet
- Related: PreparedStatement
A cursor over query rows returned by executeQuery, starting before the first row and advanced with next. Column values are read by index, which is 1-based, or by label.
- CallableStatement
- Related: PreparedStatement
A JDBC statement for invoking stored procedures, with parameters registered via registerOutParameter and read after execution with typed getters.
- ResourceBundle
- Related: Locale, MessageFormat
A container of locale-specific objects loaded by base name plus locale, falling back from specific to default bundles. Properties-based bundles are the common text-localization mechanism.
- Locale
- Related: ResourceBundle, NumberFormat
A class representing a language, country, and optional variant used to select formatting and bundle behavior. Constructed with language tags or constants, and matched via candidate locale lookup.
- MessageFormat
- Related: ResourceBundle, Locale
A formatter that builds localized messages from patterns containing numbered placeholders, applying locale-specific number and date formatting. Choice patterns select text by numeric value.
- NumberFormat
- Related: Locale
A formatter and parser for locale-sensitive numbers, currencies, and percentages, obtained from factory methods rather than constructors. It also controls grouping and fraction digits.
- Path
- Related: Files, FileSystem
The NIO.2 interface representing a hierarchical location of a file or directory, created via Paths.get or a FileSystem. It is immutable, does not require the target to exist, and supports normalization and resolution.
- Files
- Related: Path, FileSystem
A utility class of static NIO.2 methods for copying, moving, deleting, reading, writing, and inspecting files, plus walking directory trees with a stream. Most methods throw IOException on failure.
- FileSystem
- Related: Path, Files
The NIO.2 abstraction for a storage system that creates paths, watches for changes, and provides separators. Obtained from FileSystems, allowing zip or in-memory filesystems.
- Instant
- Related: ZonedDateTime, Duration
An immutable point on the UTC timeline with nanosecond precision, the natural bridge between the date-time API and legacy Date. It is not tied to any time zone or calendar.
- ZonedDateTime
- Related: Instant, Period
A date-time with a full time zone and offset, handling daylight-saving gaps and overlaps. Prefer it over LocalDateTime when the actual instant matters.
- Period
- Related: Duration, ZonedDateTime
An amount of time expressed in years, months, and days for date-based arithmetic, distinct from a time-based Duration. Adding it to a date adjusts calendar fields, not fixed hours.
- Duration
- Related: Period, Instant
A time-based amount measured in seconds and nanoseconds, used for differences between instants or times. It differs from Period, which counts calendar days and months.
- DateTimeFormatter
- Related: Instant
An immutable formatter and parser for date-time objects, built from patterns or localized styles. It is thread-safe, unlike SimpleDateFormat, and throws on invalid patterns.