answersLogoWhite

0


Best Answer

If a single class inherits from two other classes, each of which has the same function implemented, how can we tell which one to call? This ambiguity often leads to non-deterministic behavior of classes in multiple inheritance languages.

User Avatar

Noemy Grady

Lvl 10
2y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

16y ago

Because it can cause a lot of confusion, say when both the classes from which you want the child class to inherit from, has a method with same name and signature, the compiler will not know which method to choose. Between if you really want to implement multiple inheritance there are workarounds usigng interfaces, for which you can Google.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Multiple Inheritance is the process whereby a child can be derived from more than one parent class. The advantage of multiple inheritance is that it allows a class to inherit the functionality of more than one base class thus allowing for modeling of complex relationships. The disadvantage of multiple inheritance is that it can lead to a lot of confusion (ambiguity) when two base classes implement a method with the same name.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Advantages of multiple inheritances:

· Multiple inheritance allows a class to inherit the functionality of more than one base class thus allowing for modeling of complex relationships

· You categorize classes in many ways. Multiple inheritance is a way of showing our natural tendency to organize the world. During analysis, for example, we use multiple inheritance to capture the way users classify objects.

· By having multiple super-classes, your subclass has more opportunities to reuse the inherited attributes and operations of the super-classes.

Disadvantages of multiple inheritances:

· Some programming languages (such as Java) do not allow you to use multiple inheritances. You must translate multiple inheritance into single inheritance or individual java interfaces. This can be confusing and difficult to maintain because the implemented code for categorizing objects is quite different fro the way the user organizes those objects. So, when the user changes their mind or adds another category, it is difficult to figure out how to program the new sub classes.

· The more super classes your sub class inherits from the more maintenance you are likely to perform. If one of the super classes happens to change, the sub class may have to change as well.

· When a single sub class inherits the same attribute or operation form different super classes, you must choose exactly which one it must use.

Multiple inheritances can cause a lot of confusion, say when both the classes from which you want the child class to inherit from, has a method with same

Muhammad Shahbaz

Linux Administrator

Other Responses:

The Eiffel language and method was designed from the ground up to have multiple inheritance without ANY of the `gotchas' of languages like Java, C++ and others. The `disadvantages' listed above have nothing to do with MI, but with the technique and technologies listed (e.g. Java or C++). When MI is designed thoughtfully into a language and method, then the `dangers' or `disadvantages' are not there. As an Eiffel engineer, we use MI extensively, safely and beneficially all the time.

This answer is:
User Avatar

User Avatar

Wiki User

16y ago

One of the main disadvantages of inheritance in Java (the same in other object-oriented languages) is the increased time/effort it takes the program to jump through all the levels of overloaded classes. If a given class has ten levels of abstraction above it, then it will essentially take ten jumps to run through a function defined in each of those classes (the toString method, for example).

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

If a single class inherits from two other classes, each of which has the same function implemented, how can we tell which one to call? This ambiguity often leads to non-deterministic behavior of classes in multiple inheritance languages.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

The only real disadvantage of having multiple constructors is that it can increase code size unecessarily if certain constructors are actually redundant. However, multiple constructors are useful in that they make it easier for consumers to construct objects of your class in more than one way. All classes other than singleton classes should have at least two constructors anyway: a default constructor (with or without arguments) and a copy constructor. Overloading the default constructor with default values is often the best approach, but there is no real harm in creating multiple overloaded constructors if it makes it easier for consumers to construct objects from your class.

This answer is:
User Avatar

User Avatar

Mayuri Jain

Lvl 2
3y ago
  1. Static method cannot be Override.

  2. Contractors cannot be Override.

This answer is:
User Avatar
User Avatar

Mayuri Jain

Lvl 1
3y ago
😊😊🙏

User Avatar

Wiki User

15y ago

It quick and only needs one organism. All organisms are genetically identical so can be wiped out easily by disease.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Disadvantages of multiple inheritance
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How can you write multiple inheritance program in java?

Java does not support direct multiple inheritance. You can implement partial multiple inheritance using interfaces. ex: public class ExMultInherit implements interface1, interface2, interface 3 { ... .... ...... }


Give the structure of multiple inheritance?

Java does not support multiple inheritance. It is done with the help of interfaces in java. a class can implement n number of interfaces, thus showing multiple inheritance. but a class cannot extend multiple classes in java.


Drawbacks of multiple inheritance in c plus plus?

There are no drawbacks to multiple inheritance if multiple inheritance is precisely what is required to achieve your goal. If there are any drawbacks then it is only because of poor design, not multiple inheritance itself. For instance, when designing classes to simulate vehicles, an amphibious vehicle would inherit the properties of both an off-road vehicle and a marine vehicle, therefore multiple inheritance would be an appropriate usage.


Does hybrid inheritance consist of ANY two types of inheritance?

There are only two types of inheritance to begin with: single inheritance and multiple inheritance. Since they are mutually exclusive there is no such thing as hybrid inheritance.


How ploymorphism and inheritance is different from that in Java and c plus plus?

C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.

Related questions

How can you write multiple inheritance program in java?

Java does not support direct multiple inheritance. You can implement partial multiple inheritance using interfaces. ex: public class ExMultInherit implements interface1, interface2, interface 3 { ... .... ...... }


What is ambiguity in multiple inheritance?

Java does not support multiple inheritance


Different types of inheritances?

Single Inheritance Multiple Inheritance Multilevel Inheritance


What type of inheritance pattern are these rabbits likely displaying?

Types of dominance, multiple alleles, sex linked inheritance, polygenic inheritance and maternal inheritance.


Give the structure of multiple inheritance?

Java does not support multiple inheritance. It is done with the help of interfaces in java. a class can implement n number of interfaces, thus showing multiple inheritance. but a class cannot extend multiple classes in java.


What kind of inheritance is not allowed in java?

Java does not allow the multiple inheritance of concrete classes, though it does allow a "hybrid" inheritance of one concrete class and multiple interfaces.


Drawbacks of multiple inheritance in c plus plus?

There are no drawbacks to multiple inheritance if multiple inheritance is precisely what is required to achieve your goal. If there are any drawbacks then it is only because of poor design, not multiple inheritance itself. For instance, when designing classes to simulate vehicles, an amphibious vehicle would inherit the properties of both an off-road vehicle and a marine vehicle, therefore multiple inheritance would be an appropriate usage.


Why is multiple inheritance not possible in C?

C is not object-oriented -- you can't even use single inheritance let alone multiple inheritance.


What is problem in multiple inheritance?

Java does not support direct multiple Inheritance. Harder to implement, not every language support it: C++ does, Java does not.


Which two terms best describe the inheritance of human blood types?

Mendelian inheritance, multiple alleles.


Disadvantages of the patrilineal inheritance system?

The patrilineal inheritance system has several disadvantages, including: Gender Inequality Family Conflicts Disinherited Children Inefficient Resource Allocation Inflexibility


How does inheritance support multiple inheritance in java in example?

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces. Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…} And this is under the assumption that Car and Automobile are interfaces. Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.