KnowledgeBoat Logo
|

Computer Applications

What is a no-argument constructor? Does every class have a no-argument constructor?

Java Constructors

3 Likes

Answer

A no-argument constructor is a constructor that accepts no arguments and has no statements in its body. It is also called the default constructor.

If the programmer has not explicitly defined a constructor for the class then Java compiler automatically adds a no-argument constructor/default constructor. However, if the constructor is defined explicitly then no-argument constructor is not added.

Answered By

1 Like


Related Questions