answersLogoWhite

0


Best Answer

Interfaces have only methods declared and not defined. So that these various methods can be altered or customized or written according to the need. Hence Multiple inheritance is implemented through Interfaces.

Interface is a progam which just declares various methods or functions, so that any user can write the contents of that method declaration.

AnswerTrue Multiple Inheritance refers to the ability to inherit from multiple CLASSES. Thus, a true multiple inheritance language does not use interfaces. However, many single-inheritance languages provide most of the benefits of the multiple inheritance concept by using interfaces (Java, for example).

The problem with true Multiple Inheritance is twofold:

(a) at the compiler and runtime level, it is often difficult to determine which method is being referred to, as M.I. can lead to very convoluted (and sometimes conflicting) namespaces

(b) there is no specific superclass, which can lead to problems with determining relationships between classes

Using a S.I. model with interfaces avoids these two problems.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

The people who designed Java decided that they wanted to do away with some of the problematic language features of C++. One of these features was multiple inheritance.

The goal was to never have multiple implementations of the same method. By allowing a class to only have a single line of concrete implementations in its class hierarchy, they managed to achieve this goal.

It can be better understood with this example. Suppose, if you had a method with same signature in two classes, there arises an ambiquity in the class which inherits both the classes as of which method to implement. Either the method in the first class or the second class? To avoid this ambiquous situcations, Java simply avoided multiple inheritance.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why is multiple inheritance implemened through interfaces?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to write a code for a program that uses inheritance?

Multiple Interfaces are usually associated with name ambiguity and this is the reason that they haven't been implemented in .NET. However in order to incorporate the advantages of multiple inheritance keeping aside the issues involved, .NET has come up with one more concept known as INTERFACE. Interfaces allow a class to inheirt behavioral characteristics frm more than one object type called interfaces. Classes implement the interfaces. You can check out the associated links for a number of examples demonstrating above concept.


Which type of inheritance does not support by java?

Desoola Anil Kumar, Java Faculty: There are 5 types of Inheritance. 1.Single inheritance, 2.Multiple inheritance, 3.Multilevel Inheritance, 4. Hirarichal inheritance and 5. Hybrid inheritance. Java supports multi level inheritance and hirarichal inheritance.


Why does Java support multilevel inheritance?

Because it is one of the most important and widely used inheritance concepts in Java. In multi level inheritance a class directly inherits features from one class and indirectly inherits features form other classes that are in the inheritance hierarchy.


Disadvantages of multiple inheritance?

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.


What is a virtual base class in C plus plus when the different methods in base and derived classes have the same name true or false?

False. A virtual base class is one that is common to two or more derived classes that are themselves base classes, and that may be combined through multiple inheritance. By declaring the common base class to be virtual in its direct derivatives, only one instance of the common base class exists in the multiple-inheritance classes.

Related questions

How to write a code for a program that uses inheritance?

Multiple Interfaces are usually associated with name ambiguity and this is the reason that they haven't been implemented in .NET. However in order to incorporate the advantages of multiple inheritance keeping aside the issues involved, .NET has come up with one more concept known as INTERFACE. Interfaces allow a class to inheirt behavioral characteristics frm more than one object type called interfaces. Classes implement the interfaces. You can check out the associated links for a number of examples demonstrating above concept.


what does the phrase garmin 60cx mean?

The phrase garmin 60cx means you can transfer multiple maps through intrusive and extrusive http://www.asiteaboutnothing.net/g_60csx.html interfaces.


What is the use of interfaces extension through inheritance?

Interfaces are extremely useful in creating inheritance hierarchies in java programs. Interfaces cannot be extended but they will be implemented. Ex: public Interface Interface1 { public String getName() {}; } public Interface Interface2 { public int getAge() {}; } public class InterfaceExample implements Interface1, Interface2 { public String getName() { return "Anand"; } public int getAge() { return 28; } } Here I have implemented two interfaces in a class. I must provide implementation for all the methods that are declared inside both interfaces. So for simplicity I have just written 1 method in each interface but in practical situations you may have numerous methods inside each interface.


Who can tell me what is inheritance tax?

Inheritance tax is the tax that you have to pay if you gain some kind of income through an inheritance fund. It is like adding to the income you gain through inheritance.


How do you implement multiple inheritance through interface in java?

The multiple inheritance is supported by using more implements key word example class a implements b, implements c, implements d { .... } so here the class a supports multiple inheritance by implementing class b,c,d. Java does not support true multiple inheritance - true M.I. requires that a class be able to inherit directly from multiple classes. That is, in M.I., Class A can be a direct child of Class B and C. To get much of the functionality and advantages of the M.I. model, Java uses Interfaces. Thus, a Java Class A will be the child of Class B, but can implement several interfaces X, Y, and Z. This attempts to mimic the behavior that in a M.I. language would be given by Class A being a direct child of B, X, Y, and Z. The major difference between a M.I. language and a single-inheritance language with interfaces (like Java), is that interfaces can only define the method signatures and constants; they CANNOT provide implementations of those methods in the interface specification. Thus, any class which implements a given interface must provide an actual implementation of the methods that the interface describes. The big downside to this is that it can lead to a large amount of "code copying" - that is, if both Class A and Class B implement an interface X, there is a good chance that most of the methods from X will have the same code implementation in both Class A and B. Sometimes this is unavoidable; however, it is also considered good programming style to use abstract Classes to implement commonly used interfaces, then put that abstract class fairly high in the object hierarchy, allowing large numbers of classes to inherit from that abstract Class (which, in turn, means they have access to the implementation of those interfaces without having to copy the code). The advantage of interfaces is that they can keep things conceptually clean, and also make it simple for classes to decide how they want to implement the method contract the interface describes. Practically speaking, if you would like Class A to inherit from Class B and also to inherit from Class C, then, in Java, you would simulate this via interfaces this way: public class B { // the superclass methods_go_here_with_their_implementations; } public interface C { // the Java equivalent of Class C in a M.I. Language the_method_signatures_of_C_go_here; } public class A extends B implements C { implementations_of_methods_in_C_go_here; }


Which type of inheritance does not support by java?

Desoola Anil Kumar, Java Faculty: There are 5 types of Inheritance. 1.Single inheritance, 2.Multiple inheritance, 3.Multilevel Inheritance, 4. Hirarichal inheritance and 5. Hybrid inheritance. Java supports multi level inheritance and hirarichal inheritance.


What is inheritance in science terms?

Inheritance is the process by the which traits or characteristics pass from parents to their offspring through genes. Some of these characteristics are dominant and some are recessive and they are passed through inheritance.


What is the difference between cytosplasmic and mendelian inheritance?

To make this simple cytoplasmic inheritance is the inheritance of genes in organelles such as mitochondria that do not go through regular mitosis which is Mendelian inheritance. It is a bit more complex than this and can be easily Googled.


Is inheritance pass through blood?

Yes it is passed through blood sometimes but mostly through DNA


What inheritance of traits can be traced by geneticists through?

DNA Fingerprint


The inheritance of traits can be traced by geneticists through?

DNA Fingerprint


The inheritance of traits can be traced by geneticists through what?

DNA Fingerprint