When superclass just defines the structure of the methods without providing complete implementation of every method and the subclass overrides the abstract methods in superclass and implements them, then the superclass is called as abstract class.
superclass specifies 'abstract' type before the methods who's structure is defined and implementation is not provided. We call these methods as abstract methods.
For example: - abstract methodname( );
The class that has at least one abstract method need to be specified as 'abstract' before the class name
//Body of the class
Implementation for the abstract methods in the superclass will be provided in the sub classes which overrides the abstract methods of superclass.
Lets implement this on Eclipse IDE:
1. Create superclass 'Superclass' which contains abstract method whose structure is provided but implementation is not provided as shown below and save:
5. Observe that the output is displayed in the console as shown below:
Click here to download the project containing the 'Superclass', 'Subclass' and 'AbstractDemo' class files used in this post (You can download the project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
Prevent Overriding using 'final' keyword will be explained in the next post.