Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

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

Entries: 5788

Java

TreeMap(): natural key ordering and grouping

`TreeMap()` creates an empty map that sorts keys by their natural order. Use `TreeMap::new` as the map supplier when `groupingBy` should return sorted group keys.

Intermediate · Java SE 21
Java

WeakReference — a weak reference to an object

WeakReference<T> holds a weak reference that does not prevent the garbage collector from reclaiming an object. Reading it through get() may return null; clear() clears the reference without destroying the object itself.

Intermediate · Java SE 21; repository runtime, production runtime not attested
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