Ask Question
16 April, 15:02

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.

+1
Answers (1)
  1. 16 April, 18:58
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers