Tutorial Description - Constructors
A constructor is used when creating an object from a class. The constructor name must match the name of the class and must not have a return type. They can be overloaded, but they are not inherited by subclasses.
A constructor is used when creating an object from a class. The constructor name must match the name of the class and must not have a return type. They can be overloaded, but they are not inherited by subclasses.
Invoking constructors
A constructor can be invoked only from other constructors. To invoke a constructor in the same class, invoke the this() function with matching arguments. To invoke a constructor in the superclass, invoke the super() function with matching arguments. When a subclass object is created, all the superclass constructors are invoked in the order starting from the top of the hierarchy.