Re: Java-Multiple inheritance
Check the following scenario:
class A{
void method1(){
//some code here
}
}
class B{
void method1(){
// some code here
}
class C extends A,B { //do not try..not possible in java
//assuming it inherits method1() method
}
class JavaMultipleInheritenceTest{
public static void main(String args[]){
C cObj=new C();
cObj.method1();//creates an ambiguous situation for JVM to detect which
class's overridden method method1() it is asking for(classA or class B)
}
}
This is the reason in Java we cannot extend multiple classes but can extend multiple interfaces.
__________________
"If people never did silly things, nothing intelligent would ever get done" -Ludwig Wittgenstein
|