InterviewSolution
| 1. |
Describe Inheritance And Non-inheritance Of A Derived Class? |
|
Answer» Using inheritance, you can derive all the data members and all the other common FUNCTIONS of the BASE class and still retain the functionality of the common methods of the base class. For example, the animal class with eat, sleep and breathe methods COMPRISES the base class because they are common to all animals. Now, a new class ELEPHANT with a method trumpet is derived from the class animal. With the help of inheritance, the Elephant class inherits the trumpet method and still retains the eat, sleep, and breathe methods from the base class, animal. Using inheritance, you can derive all the data members and all the other common functions of the base class and still retain the functionality of the common methods of the base class. For example, the animal class with eat, sleep and breathe methods comprises the base class because they are common to all animals. Now, a new class Elephant with a method trumpet is derived from the class animal. With the help of inheritance, the Elephant class inherits the trumpet method and still retains the eat, sleep, and breathe methods from the base class, animal. |
|