J.III · Java 25 practice question
Where are type variables introduced in the Java language according to JLS SE 25?
Check answer and explanation
Correct answer: By declaring a type parameter of a generic class, interface, method, or constructor
Explanation
Type variables are introduced by type parameter declarations on generic classes, interfaces, methods, or constructors.
Common trap
Using a class literal inside a static block produces a Class object rather than introducing a type variable. Importing a static constant only brings a member name into scope. Importing a static constant only brings a member name into scope.
Source: JLS SE 25 §4.4. Type Variables
Checked against the cited text on 2026-11-25.