Every class, even an abstract class, has at least one constructor.
Constructors must have the same name as the class.
Constructors don't have a return type.
Constructors can use any access modifier, even private!.
The compiler will create a default constructor if you don't create any constructors in your class.
The default constructor is a no-arg constructor with a no-arg call to super().
A constructor is always invoked when a new object is created.
The constructor calls its superclass constructor, which calls its superclass constructor.
The first statement of every constructor must be a call to either this() (an overloaded constructor) or super().
The compiler will add a call to super() unless you have already put in a call to this() or super().
Instance members are accessible only after the super constructor runs.
Abstract classes have constructors that are called when a concrete subclass is instantiated.
If your superclass does not have a no-arg constructor,
you must create a constructor and insert a call to super() with arguments matching those of the superclass constructor.
Constructors are never inherited, thus they cannot be overridden.
|