Thursday 7 November 2013

Why java does not support multiple inheritance or diamond problem in multiple inheritance

package com.javaeasy;

class A {
public void add() {
System.out.println("I am in class A");
}

}

class B extends A {
public void add() {
System.out.println("I am in class B");
}

}

public class NotSupportingMultipleInheritance extends A,B {

//Confusion seen here and cant decide to call class A or B method
//Diamond Problem

public static void main(String[] args) {
// TODO Auto-generated method stub
NotSupportingMultipleInheritance obj=new NotSupportingMultipleInheritance();
obj.add();

}

}


1 comment: