Practice mode Java

What does the Java compiler provide when a class declares no constructors at all?

Correct answer B. A default constructor with no parameters

Explanation

If a class body contains no constructor declarations, the compiler implicitly supplies a default constructor with no parameters that simply calls super(). It has the same access level as the class. Declaring any constructor yourself, even one with parameters, removes this default, which is why code calling new X() can suddenly stop compiling.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.