What are the base class, sub class, and superclass?

Asked 07-Dec-2019
Viewed 624 times

1 Answer


0

The base class, sub class and super class are concepts used in polymorphism. Polymorphism is one of the many features that are provided by OOPS (Object Oriented Programming)

A base class is a class from which other classes are obtained. It helps in creation of other classes which can implicitly and elegantly reuse code.

A sub class is a class that inherits from the base class or super class. It reuses the code from the base class.

Super class is a class from which all other classes inherit.

For instance, let us consider the example of birds. Suppose we have a class named BIRD. This BIRD class is the base class whereas all the other classes like PARROT, CROW and all are sub classes of the BIRD class. Again, the BIRD class is the superclass of PARROT, CROW and all.