J.III · Java 25 practice question

A programmer defines a non-generic class PlainTask that has no explicit extends clause. According to JLS SE 25, what counts among its direct supertypes?

Choose one answer
Check answer and explanation

Correct answer: The direct superclass type of PlainTask and its direct superinterface types

Explanation

For a non-generic class, its direct supertypes include its direct superclass type (if it is a class) and its direct superinterface types.

Common trap

Omitting the superclass type ignores the direct superclass rule for classes. Assuming unrelated generic interfaces are included invents supertypes not given by the declaration. Assuming unrelated generic interfaces are included invents supertypes not given by the declaration.

Source: JLS SE 25 §4.10.2. Subtyping among Class and Interface Types
Checked against the cited text on 2026-11-25.

Report an error in this question