Skip to content
UniCircle
EasyConceptualConstructors

Constructors: default, no-arg and parameterised

Question JAVA-CON-018

What kinds of constructors does Java have? When does the compiler add a default constructor, and when does it stop?

Show the explanation

A constructor has the class name and no return type; it runs when new creates an object.

  • Default constructor — added by the compiler only if you write no constructor at all. It takes no arguments and just calls super().
  • No-arg constructor — one you write yourself with no parameters.
  • Parameterised constructor — takes arguments to initialise the fields.
Java
class Student {
    private final String name; private int year;
    Student(String name, int year) { this.name = name; this.year = year; }
    Student(String name) { this(name, 1); }      // chaining to the main constructor
}
// new Student();   // compile error: once you add any constructor, no default one is generated

That last point causes a classic error: if a parent class declares only a parameterised constructor, every subclass constructor must call super(args) explicitly, because the implicit super() has nothing to call. Java has no built-in "copy constructor", but you can write one (Student(Student other)) as a clear alternative to clone().

Original UniCircle question. Last reviewed 22 Oct 2026.