GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 395 of 493    Print  
How the Multiple Inheritance is problematic. In other words why this feature from C++ is not taken into Java?

  
Total Answers and Comments: 3 Last Update: May 07, 2008     Asked by: jcgeorge 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 14, 2007 06:53:45   #1  
g4java Member Since: July 2007   Contribution: 28    

RE: How the Multiple Inheritance is problematic. In ot...
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 :)

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
February 14, 2008 03:47:46   #2  
sampra Member Since: February 2008   Contribution: 279    

RE: How the Multiple Inheritance is problematic. In other words why this feature from C++ is not taken into Java?
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

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
May 07, 2008 03:00:45   #3  
bewithmd Member Since: May 2008   Contribution: 1    

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

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


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape