Abstract Method / Class
In this section, we study abstract method and class.
Introduction to Abstract Method/Class
The abstract method does not provide any implementation.In fact, it does not even have a body ( { } ) and ends with a semicolon (;).
The abstract method is a "missing piece" in the class.
If a class contains abstract methods, it must be declared as an abstract class.
An abstract class is an incomplete class because it has “missing pieces”.
Therefore, an abstract class cannot be instantiated due to its incompleteness,
but subclasses can inherit from it.
Abstract classes are used only as superclasses in inheritance hierarchies.
The purpose of abstract class is to provide an appropriate superclass from which other classes can inherit.
They specify what is common among subclasses.
An abstract class normally contains one or more abstract methods (static methods cannot be abstract).
Each concrete subclass must provide concrete implementations of the superclass’s abstract methods, or declare itself as abstract.
Constructors are not inherited, cannot be abstract.
We can declare reference variables of abstract superclasses and use them to hold references to objects of any concrete subclass.