J.VIII · Java 25 practice question

A developer writes `module com.example.app {}` without any `requires` directives. Can code in `com.example.app` still use types from `java.base`?

Choose one answer
Check answer and explanation

Correct answer: Yes, every module other than java.base has an implicitly declared dependence on java.base if not stated

Explanation

Whenever a module declaration other than java.base does not explicitly require java.base, it automatically has an implicitly declared dependence on java.base.

Common trap

While other JDK modules like java.sql must be required explicitly, java.base is a special case that is always implicitly required. No compiler flag is needed; the implicit dependence on java.base is mandated directly by the Java Language Specification.

Source: JLS SE 25 §7.7.1. Dependences
Checked against the cited text on 2026-11-25.

Report an error in this question