Ask Question
9 September, 22:54

Among object-oriented languages, one feature that varies considerably is whether the language allows multiple inheritance. C+ + does but Ada does not. Java takes a middle ground approach of allowing multiple inheritance of interfaces but not classes. Using a C+ + example, illustrate some of the complexities that multiple inheritance introduces. How does C+ + deal with them? Why does Java's middle ground approach offer some of the benefits of multiple inheritance while avoids its problems.

+5
Answers (1)
  1. 10 September, 00:32
    0
    Multiple inheritance causes Diamond problem which happens when:

    Class A is parent of class B and C

    Now when class D will be inherited from both Class B and C it will have all the members of class A and B which if same will confuse the compiler to import which one?

    C+ + solves it by using virtual keyword with them and thus telling the compiler which one to inherit.

    Java has introduced the interface concept rather then allowing multiple inheritance.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Among object-oriented languages, one feature that varies considerably is whether the language allows multiple inheritance. C+ + does but ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers