Inheritance
A Programming technique that is used to reuse an existing class to build a new class is known as inheritance.The new class inherits all the behavior of the original class.the class existing class that is reused to create a new class is known as a superclass, base class or parent class.The new class that inherits the properties and functions of an existing class is known as a subclass, derived class or child class.The inheritance relationship between the classes of a program is called a class hierarchy.
Example:
Suppose we have a class named Vehicle.The subclasses of this class
may share similar properties such as wheel and motor etc.Additionally, a subclass may have its own particular characteristics.For example, a subclass Bus may have seats for people cut another subclass Truck may have space to carry goods.
A class of animals can be divided into subclasses like mammals, amphibians, insects, reptiles.A class of vehicles cam ve divided into cars, trucks, buses, and motorcycles, A class o shapes can be divided into the subclasses lines, ellipses, boxes.
0 comments: