ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories >> Software >> Java-Related >> Java-J2EE >> Core-Java
 
 
 
Question
Why java Don't Support Multiple interitence
 Question Submitted By :: Manishjavaguru
I also faced this Question!!     Rank Answer Posted By  
 
Answer
There is a big reason behind that(java does not support 
multiple inheritance). Please go through the following 
example.

1. Assume that java is supporting multiple inheritance 

class A {

  void m1() {
        // implement method 
  }
}

class B {
  void m1() {
        // implement method
  }
}
//As for the assumption (1) the following code will compile

class C extends A,B {

   public static void main( String s[]) {
   
     C c = new C();
     c.m1();
   }
}

Note : In main method i am calling c.m1() method In this 
situation which super class m1 method has to call (from A 
or B) JVM will confuse.

So our assumtion(1) is wrong .

This is the  reason why java does not support multple 
inheritance through classes.

Note : This same cocept is applicable for classes.
 
0
Bhaskar Reddy
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com