Define an abstract class. Explain its purpose. A class with one or more abstract methods is called an Abstract class. An abstract method is a method with signature with out code in it.
The purpose of an abstract class is to implement the concept of abstraction that is what to do, but not why to do.
For example, circle, square, triangle are the shapes in geometry. Each of these are shapes, whose super class is Shape. Each of them have perimeter and area which cannot be defined in the super class, say Shape. And without Shape none of these exist.
In the above scenario, a method, say calculateArea() can not be defined in the super class Shape though every ‘Shape’ have area. The solution is to declare the Shape as an abstract class which has calculateArea () as an abstract method.
The concrete implementation of the calculateArea () method is to be implemented in the Circle, Square and Triangle classes which are sub classes to the abstract class Shape.