J.II · Java 25 practice question

In a normal class declaration, a developer writes a constructor with no access modifier at all. What accessibility does that constructor have?

Choose one answer
Check answer and explanation

Correct answer: Package access, making it accessible within the same package.

Explanation

In a normal class declaration, a constructor declared with no access modifiers has package access.

Common trap

Only a compiler-generated default constructor mirrors the class's public modifier; an explicitly written constructor with no modifier gets package access. Omitting an access modifier in Java never grants protected access to subclasses in other packages.

Source: JLS SE 25 §8.8.3. Constructor Modifiers
Checked against the cited text on 2026-11-25.

Report an error in this question