Hi;
Multi-Inheritance is not supported in Java as is supported by C++.
Multi-Inheritance is a case where the sub-class inherits multiple properties
from several classes; more than one. Instead, Java provides interfaces for
Multi-inheritance.
class A {
.......
}
class B {
.......
}
class C {
.......
}
interface D {
.......
}
interface E {
.......
}
interface F {
.......
}
class G extends A implements D, E, F {
.......
}I hope this help! I'll provide much examples and information as my exams finish! With the hope of rising of Mahdi; Ali Shakiba Shahid Bahonar University of Kerman Iran - Kerman On Mon, Feb 8, 2010 at 8:33 AM, Salish S <[email protected]> wrote: > /*Hi all , > Please help me in inheritance , > what in multiple inheritance > what is the use? > please go through the example and help me.......... > */ > > //parent class > class A{ > public void printA(){System.out.println("in the class A");}//simple method > in parent class > public void printB(){}//if A b=new B(); is using then this method be also > in the parent class WHY? as in interface so what is the differnce > public void printC(){}// new C(); "" > "" > } > //subclass B > class B extends A{ > public void printB(){ > this.printA();//if A a=new A();then a.printA() then also get the output > in the class A then why use the extends A > System.out.println("in the class B");} > } > //subclass C > class C extends A{ > public void printC(){ > super.printA();//if A a=new A();then a.printA() then also get the output in > the class A then why use the extends A > System.out.println("in the class C");} > } > //the main class > class D extends A{ > public static void main(String ar[]){ > A b=new B();//B b=new B(); if this is the case there is no need of printB > &printC in the parent class is this necessary for interface > A c=new C();//C c=new C(); > b.printB(); > c.printC(); > System.out.println("hi hello in the main class the D"); > } > } > //even though the A a=new A();a.printA(),B b=new B() then b.printB() & C > c=new C(); c.printC() all will give the wanted out put then why are we > going > //behind the interface ,abstract class,etc..... > //please change the programe to interface option and abstract option so > that i can get the use in a helpful manner > //thanks > > -- > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected]<javaprogrammingwithpassion%[email protected]> > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
