Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Java

Knowledge base — Java

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 813

Java

ZoneId.of: select a time zone by ID

Use `ZoneId.of` to select a regional time zone or fixed UTC offset and display the same instant in Warsaw, New York, and Tokyo.

Intermediate · Java SE 21
Java

ZoneOffsetTransition — local-time gaps and overlaps

ZoneOffsetTransition describes a change in UTC offset. The isGap() method identifies a gap, while getDateTimeAfter() returns the local date-time at the transition boundary using the new offset.

Intermediate · Java SE 21; repository runtime, production runtime not attested
Java

ZoneRules — valid offsets and clock transitions

ZoneRules describes changes to a zone's offset. Its getValidOffsets and getTransition methods detect nonexistent or ambiguous local times before an offset is selected.

Intermediate · Java SE 21; repository runtime, production runtime not attested
Java

Java program architecture

Java program architecture: Java architecture uses package and JPMS module boundaries: module-info.java declares requires, exports, opens, uses, and provides, while the JVM loads compiled bytecode. A fluent builder with a recursive self type, such as B extends Builder<B>, preserves the concrete builder type across chained methods and inheritance.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Asynchrony and concurrency in Java

Asynchrony and concurrency in Java: Java 21 concurrency includes Thread, ExecutorService, Future, CompletableFuture, and virtual threads, while the Java Memory Model defines visibility through happens-before relations. The Java Memory Model (JMM) defines cross-thread reads; for ordinary mutable or non-final state, safe publication requires happens-before from completed initialization to the reader.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Boxing, unboxing and wrapper cache identity

Boxing converts a primitive value to a wrapper object, while unboxing retrieves its value. Learn how == differs from equals and why null and shared wrapper instances can cause surprises.

Intermediate · Java SE 21; repository runtime, production runtime not attested
Java

Java collections

Java collections: The Java Collections Framework separates Collection, List, Set, Queue, and Map interfaces from implementations, with equality, ordering, and mutability contracts determined by the type.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Comments and documentation in Java

Comments and documentation in Java: Java recognizes line //, block /* ... */, and documentation /** ... */ comments; javadoc interprets tags and generates API documentation from doc comments.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Conditional control flow in Java

Conditional control flow in Java: Java selects control flow with boolean if/else or a switch statement or expression, which in Java 21 supports type and record patterns, when guards, and case null.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Data pipelines in Java

Data pipelines in Java: A Java data pipeline commonly combines a source, lazy Stream intermediate operations, and one terminal operation; elements are pulled only as needed.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Deep immutability and defensive copying

A `final` field does not freeze an array. Copying mutable data on both input and output keeps shared references from changing an object's state.

Advanced · Java SE 21
Java

Defensive collection copying

Copy a list in the constructor and in `getRoles()` so callers cannot modify the list stored in a DTO. A `final` field alone does not provide that protection.

Advanced · Java SE 21
Java

DTOs and domain objects: explicit mapping

Separate data sent across a boundary from domain state and behavior. Map five fields explicitly to create independent snapshots that never carry `passwordHash`.

Advanced · Java SE 21
Java

Exceptions and error handling in Java

Exceptions and error handling in Java: Java reports failures as Throwable: Error normally represents JVM-level problems, Exception covers application conditions, and RuntimeException is unchecked.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Expressions and operators in Java

Expressions and operators in Java: Java expressions evaluate left to right under fixed precedence, numeric promotion, and arithmetic, logical, bitwise, comparison, and assignment operators.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Filtering and transformations in Java

Filtering and transformations in Java: Filtering keeps elements satisfying a Predicate, map transforms each element, and flatMap expands each result into zero or more values in Stream or Optional.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Finite-state machines in Java

Finite-state machines in Java: A finite-state machine models state and event as enums or sealed types, with a transition function selecting the next state, often through an exhaustive switch expression.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Fluent builder with self type

A generic self type keeps subclass-specific methods available after inherited fluent calls. The terminal `build()` call creates a separate product from the builder’s current state.

Advanced · Java SE 21
Java

Functions and functional interfaces in Java

Functions and functional interfaces in Java: Java represents behavior with methods and with lambdas or method references targeted to a functional interface having one abstract method.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Generic method inference and boxing

Java can infer a generic method’s type arguments from the call arguments and, where applicable, the expected result type. Boxing lets an `int` argument take part in such a call as an `Integer`, not as a primitive type argument.

Advanced · Java SE 21
Java

Generics in Java

Generics in Java: Generics provide compile-time checking, while type erasure removes most type arguments and inserts casts or bridge methods; generic method inference derives arguments from parameters and the target type.

Intermediate · Java SE 21 (JLS and Java SE API); examples verified on the repository Java runtime
Java

Heap pollution in generic varargs

An `Object[]` alias lets a `List<Integer>` replace a `List<String>` in a varargs array. The store succeeds, and no exception occurs unless the element is read as a `String`.

Advanced · Java SE 21