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

The keyword provides

The keyword provides: The provides S with P directive in module-info declares that a module supplies service S through provider class P.

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

The keyword public

The keyword public: The public modifier gives a declaration the widest accessibility allowed by its context, package, and module boundary.

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

The keyword record

The keyword record: A record declaration creates a nominal data class whose components determine private final fields, accessors, and a canonical constructor.

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

requires — module dependency

requires — module dependency: A requires directive in module-info.java establishes a module dependency and a readability edge to a named module.

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

return — exit from a method or lambda

return — exit from a method or lambda: return ends execution of the current method, constructor, or lambda body and optionally supplies a value to the caller.

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

sealed — restricted type hierarchy

sealed — restricted type hierarchy: sealed restricts a class or interface’s direct subtypes to those named by permits or inferred in the same compilation unit.

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

static — class-level member

static — class-level member: static associates a field, method, initializer, or nested class with the declaring class rather than a particular instance.

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

strictfp — historical floating-point strictness

strictfp — historical floating-point strictness: strictfp historically requested strict floating-point evaluation, but since Java 17 all floating-point expressions are always-strict, so the modifier does not change results.

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

super — superclass access

super — superclass access: super selects a constructor, hidden field, or overridden method of the current object’s direct superclass; fields are hidden, not overridden. InterfaceName.super.m() selects a direct superinterface method.

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

switch — multi-way selection

switch — multi-way selection: A Switch expression selects a value among case labels; arrow rules written case ... -> do not fall through and in Java 21 support patterns and when guards.

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

synchronized — monitor locking

synchronized — monitor locking: synchronized acquires an object monitor before entering a block or method and releases it on every normal or abrupt exit.

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

this — current instance

this — current instance: this denotes the current instance in an instance method or constructor and disambiguates fields from same-named parameters.

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

throw — explicit exception raising

throw — explicit exception raising: A throw statement evaluates a Throwable expression and completes abruptly, passing the exception to the nearest compatible catch or caller.

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

throws — declaring exceptions

The throws keyword in a method or constructor declaration specifies exception types that may escape its body. It matters especially for checked exceptions: calling code must handle them or declare that they can propagate further.

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

to — making a package available to selected modules

In Java SE 21, `to` is a contextual keyword used in `exports` and `opens` directives. It identifies the modules to which the declaring module makes a particular package available.

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

transient — excluding a field from default serialization

The transient keyword excludes a field from Java's implicit list of serializable fields. If the field is omitted, it retains its default value after an ordinary Serializable object is read back, unless restoration code assigns another value.

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

transitive — transitive module readability

During module resolution, `requires transitive` makes modules that read the declaring module also read the specified dependency. A read edge added later with `Module.addReads` does not automatically extend to the target module’s transitive dependencies. `exports` and access-control rules still apply.

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

try — exception handling and resource closing

The reserved keyword `try` starts a block associated with exception handling or automatic resource closing. Ordinary `try` requires `catch`, `finally`, or both; `try`-with-resources can omit them.

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

uses — declaring service consumption in a module

The uses directive in module-info.java identifies a service type whose providers the module may discover through ServiceLoader. It neither selects a particular implementation nor starts discovery by itself. uses is a contextual keyword, not a reserved keyword.

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

var — local variable type inference

`var` lets the compiler infer a local variable's type from its initializer. The type remains static and does not change with later assignments. In Java SE 21, `var` is a contextual keyword, not a type name.

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

volatile — field visibility between threads

volatile is a reserved keyword marking a field used for communication between threads. It provides visibility and happens-before ordering guarantees, but does not provide mutual exclusion or make operations such as count++ atomic.

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

when — an additional condition on a switch pattern

In Java SE 21, the contextual keyword when introduces an additional condition (a guard) after a case pattern in a switch statement or expression. The branch is selected only when the value matches the pattern and the guard evaluates to true.

Intermediate · Language target: Java SE 21. Neither the repository runtime version nor the production runtime version is attested.
Java

while — a pre-test loop

The while keyword introduces a loop that checks its condition before each execution of its body. The body may never execute; the condition must have type boolean or Boolean.

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

with — service providers in a module

In Java SE 21, `with` is a contextual keyword in the `provides` directive of a module declaration. It separates the service type from its provider list; outside that context, it can be an identifier.

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