SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Chapter:
Object-oriented Design
Exercise:
Exercises
Question:9 | ISBN:9781118771334 | Edition: 6

Question

What are some potential efficiency disadvantages of having very deep inheritance trees, that is, a large set of classes, A, B, C, and so on, such that B extends A, C extends B, D extends C, etc.?

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer


Drawbacks of deep inheritance in java:

 

1. One of the drawbacks of deep inheritance is that the classes (parent and child) become tightly coupled.

As a result, when we change the code of the parent class, all of the child classes inheriting from the parent class will be affected, and they cannot function independently.

2. The compiler will take longer to figure out which method is overridden if the method signature is overridden in each class.

3. Classes that extend one another become disorganized.

4. Moreover, it does not support multiple inheritance in classes, but it can be done through interfaces.

Deep inheritance is a bad practise,
 

0 0

Discussions

Post the discussion to improve the above solution.