answersLogoWhite

0


Best Answer

Multiple inheritance is used when a new class to be formed has to inherit characteristics from two or more classes. eg: class scientist class labourer | | | | V V -------------------------------- | class employee | -------------------------------- Multilevel inheritance is used if a derived class inherits characteristics from a base class which is a derived class (intermmediate base class). If the inheritance level is more than two then it is a multilevel inheritance. eg: class Grandfather | | V class Father | | V class son

User Avatar

Wiki User

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

Wiki User

15y ago

* When asked in an interview or otherwise a brief answer is: "Multiple Inheritance is when a derived class inherits properties and methods from multiple classes as opposed to Single Inheritance. So, for cases where I find that I have two or more classes and another new class is to be created that has properties and behaviour of both or all the base classes then I use Multiple inheritance. For example, If base class one is Terrestrial and Base Class two is Aquatic, then the new class Amphibian will be case of multiple inheritance deriving from both the two base classes."

This answer is:
User Avatar

User Avatar

Wiki User

17y ago

Multiple inheritance is likely to be most useful when you can separate the characteristics of objects into orthogonal sets, in which the characteristics of one set do not depend on the characteristics of other sets. If you can define a class to represent each set of characteristics, you can use multiple inheritance to build complex classes with different combinations of characteristics. We gave a glimpse of how to create such a design by starting to segregate characteristics of flying and ground vehicles, and then noting that certain vehicles, like such as aircraft, can combine both sets of characteristics. Another approach that can be useful for various applications is to create one or more base superclasses, which define common characteristics of subclasses, and a number of mix-in classes, each of which adds a set of orthogonal characteristics. A mix-in class is like an addition, such as Chocolate Chips or nuts, that might be mixed into an ice-cream base. Another way to think about this approach is to imagine the base class as a noun and the mix-in classes as adjectives that modify or specialize the noun. You can then construct concrete subclasses by using multiple inheritance. For each concrete subclass, one or more mix-in classes typically precede a single base class in the list of superclasses. EXAMPLE : define abstract class () slot identifier :: , required-init-keyword: id:; ... end class ; define abstract class () slot vehicle-id :: , required-init-keyword: id:; ... end class ; define class () slot name :: , init-keyword: name:; ... end class ; define class () slot name :: , required-init-keyword: name:; ... end class ; Multiple inheritance provides several advantages in solving the name problem: 1. We localize in a single class the characteristic of having a name. 2. Subclasses can still customize aspects of the name attribute, such as what that attribute's initial value is, and whether or not it is required. 3. We can give a subclass a name attribute without redefining any of its superclasses. 4. The only subclasses that have a name attribute are those for which that is appropriate. MULTI LEVEL INHERITANCE: I believe this i got this code from others it may helps u: just experiment on it: OK, here's the code n check it: 1195c1195 < IND(s); s // scoped name. Have to use the alias for the base class in the > // global scope to refer to the virtual member function instead. > if (strcmp(intf_name,intf->wrapproxy_uqname()) != 0) { > intf_name = new char[strlen(intf->_scopename())+ > strlen(intf->wrapproxy_uqname())+1]; > strcpy(intf_name,intf->_scopename()); > strcat(intf_name,intf->wrapproxy_uqname()); > } > } > s } > s IND(s); s INC_INDENT_LEVEL(); > IND(s); s

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Multiple inheritance should be applied when it is fit into the design, like any other features, not because it must be applied because it is available, or it is fun to apply.

Multiple inheritance occurs when an object IS more than 1 thing, and being one of them, may have nothing to do with being another. For example, Apple is a kind of fruit, and it also is a computer company. As a fruit, you can compare an apple to an orange, but as a company, you can compare Apple to Sun, Oracle, Big-Blue, etc.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

Multiple Inheritance is when one class inherits the features of multiple classes simultaneously.

Note: Java does not support direct multiple inheritance

Multilevel Inheritance is when the properties of one class are extended by another class through some other class.

Ex:

public class A extends B {

...

}

public class B extends C {

...

}

public class C extends D {

...

}

Now Class A indirectly extends class D through B & C This is multilevel inheritance

Note: Java allows multilevel inheritance till any number of levels.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

Inheritance enables new classes(child class) inherit the properties and methods of existing classes(parent class). Multiple inheritance refers OOP feature in which a child class can inherit properties, methods and variables from more than one parent class while with single inheritance a child may inherit from at most one parent.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

is aterm that refers to a class that inherits functionality from more than one parent class.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When shall you use Multiple Inheritance?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

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.


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.


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 { ... .... ...... }


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.

Related questions

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 ambiguity in multiple inheritance?

Java does not support multiple 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.


Can you use multiple inheritance in .NET?

Multiple inheritance in C# In C#, the classes are only allowed to inherit from a single parent class, which is called single inheritance. But you can use interfaces or a combination of one class and interface(s), where interface(s) should be followed by class name in the signature.


Different types of inheritances?

Single Inheritance Multiple Inheritance Multilevel Inheritance


How multiple inheritance is done in java?

Java doesn't have multiple inheritance proper. It is possible for a class to implement different interfaces - however, in this case, only the method names are "inherited", not their contents. It is also possible to use composition instead of inheritance: an object can contain objects of different classes, and use the methods of the objects it contains - but this, too, is a different mechanism than 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.


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 { ... .... ...... }


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.


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.