next up previous
Next: Design methodology for a Up: Unit 03 Previous: Overloading of constructors

Standard constructor

When we create an object of a class that does not contain any constructor definition (such as the first version of the Person class), the so-called standard constructor is called.

For example, for the class Person, we could define the following constructor without arguments:

public Person() { // constructor without arguments
  name = "John Smith";
  residence = null;
}

Note: It does not always make sense to define for a class a constructor without arguments. For example, the definition of a constructor without arguments for the class Person can certainly be questioned.


next up previous
Next: Design methodology for a Up: Unit 03 Previous: Overloading of constructors