Using abstract
The keyword
abstract
is used when creating a class hierarchy.
Often when designing the hierarchy, you will find that methods in the parent class don't actually do anything.
However, if you do not write at least the signature of the method in the parent, then your hierarchy cannot take advantage of polymorphism.
Making the method abstract takes care of this.
Syntactically, by making a method abstract, you must make the class abstract.
public abstract class Abc { public abstract void method(); }
The idea is that the class is used to organize the hierarchy, but is not meant to be instantiated. In fact, it cannot be.
If a child class does not override all of the abstract methods, then it too must be abstract.
At some point, a child class will override them all, then an object can be instantiated.