Question

In: Computer Science

7. What are the different forms of Inheritance? Give an example for each.

7. What are the different forms of Inheritance? Give an example for each.

Solutions

Expert Solution

Object Oriented Programming supports 5 types of Inheritance as given below:

  1. Single inheritance

  2. Multi-level inheritance

  3. Multiple inheritance

  4. Hierarchical Inheritance

  5. Hybrid Inheritance

1. Single inheritance

This is only 1 level of inheritance in which a derived class is created from a single base class. Example - In this class B(child class) is derived from the class A(Parent class)

2. Multi-level inheritance

In this type of Inheritance, Classes are inherited in the form of levels i.e., a derived class is created from another derived class. In the following example C is derived from B and B is derived from A.

3. Multiple inheritance

In this inheritance, a derived class is created from more than one base class. And thus this derived class will implement properties of all these Base classes. In the following example, Child class C is derived from Parents class A and Class B.

4. Hierarchical Inheritance

In this inheritance, more than one derived classes are created from a single base class and futher child classes act as parent classes for more than one child classes. In the following example, Class B and Class C are derived from the same parent class A

5. Hybrid Inheritance

This is combination of more than one inheritance. Hence, it may be a combination of Multilevel and Multiple inheritance or Hierarchical and Multilevel inheritance or Hierarchical and Multipath inheritance or Hierarchical, Multilevel and Multiple inheritance. For example:-


Related Solutions

give an briefly explain 3 forms of inheritance, give an example of each?
give an briefly explain 3 forms of inheritance, give an example of each?
Define intellectual property. What are the four forms of intellectual property? Give an example of each.
Define intellectual property. What are the four forms of intellectual property? Give an example of each.
explain the principle of the inheritance give an example( CS related) of class inheritance
explain the principle of the inheritance give an example( CS related) of class inheritance
Define the three forms of the efficient market hypothesis. Give an example of each.
Define the three forms of the efficient market hypothesis. Give an example of each.
What are the different types of environmental standards?  Give an example for each type
What are the different types of environmental standards?  Give an example for each type
In 300 words, what are the different types of variables, give an example for each
In 300 words, what are the different types of variables, give an example for each
discuss the different forms of business organization for every different business organisation give one example please
discuss the different forms of business organization for every different business organisation give one example please
(a) What are the different types of spreadsheet modeling? Give a real world example for each...
(a) What are the different types of spreadsheet modeling? Give a real world example for each type where spreadsheet modeling and analysis is useful. (b) What is an infeasible linear optimization problem? How do we find if a given linear optimization problem is infeasible? Give a real world example of an infeasible linear optimization problem.
7. What are the four “Market Structures”? Please describe each Market Structure and give an example...
7. What are the four “Market Structures”? Please describe each Market Structure and give an example of a firm that belongs in each of the four Market Structures, preferably a firm that was not discussed previously. 8. What is a “natural monopoly”? Please give an example. 9. Why are natural monopolies often regulated by some sort of Government Regulatory Agency?   10. In YOUR OPINION, SHOULD THE STATE OF CALIFORNIA HAVE TAKEN OVER PG&E? Why or why not?
Name and describe the 7 layout strategies and give an example of each one
Name and describe the 7 layout strategies and give an example of each one
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT