How the Multiple Inheritance is problematic. In other words why this feature from C++ is not taken into Java?

Questions by jcgeorge

Showing Answers 1 - 7 of 7 Answers

g4java

  • Sep 14th, 2007
 

When Class C is sub class of both A and B and if A and B consists similar properties and methods then it leads to ambiguity and also it may leads to dead locks.

Anyhow its not left over, it can be achieved by interfaces in JAVA :)

  Was this answer useful?  Yes

sampra

  • Feb 14th, 2008
 

When Class C is sub class of both A and B and if A and B consists similar properties and methods so it will consume more memory and baseic concept of doveloping java is to save the memory so taht they create java for such small deviceslik moblie ipot etc

  Was this answer useful?  Yes

bewithmd

  • May 7th, 2008
 

Consider you are having 2 base classes each with 4 methods( might have same method, doesn't matter). Now you are going to create class 3 by inheriting the properties of both the base classes ( 1 and 2)

1. Is it necessary to use all the methods in class 3 ( 8 out of 8),
No you can make use of 0 methods at the min , and 8 methods at the max..
So inturn you are wasting the memory there.... if you inherit from interface it is necessary that all the methods has to be implemented by the sub class ( if at all subclass is not declared as abstract).. so there is no wastage of memory

2. As you know, methods of interface will have only declaration and the definition should be in sub class only, but in case of class you will have definition in both super class and subclass, which inturn consumes more memory than the interface.. Speed of selecting the definition is not so quick in case of class since it has lot of definition in super class(es) as well as in sub class.

3. As you know, there is no constructor for interface since it has only final variables and abstract methods. so network traffic is less while comparing the traffic with inheritance with class.

so in simple, we make use of interfaces in order to utilize the memory properly and to reduce the traffic there by improving the performance

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions