Multiple inheritance is a mechanism in which the child class inherits the properties from more than one parent classes.
Multiple Inheritance
Definition: Multiple inheritance is a
mechanism in which the child class inherits the properties from more than one
parent classes.
For
example
• Java does not support multiple inheritance
because it creates ambiguity when the properties from both the parent classes
are inherited in child class or derived class. But it is supported in case of
interface because there is no ambiguity as implementation is provided by the
implementation class.
• Implementation
interface
A
{
void
display1
}
interface
B
{
void
display2();
}
class C
implements A,B
{
public
void display1()
{
System.out.println("From
Interface A");
}
public
void display2()
{
System.out.println("From
Interface B");
}
public
static void main(String args[])
{
C obj =
new C();
obj.display1();
obj.display2();
}
Output
From
Interface A
From
Interface B
Program
Explanation:
Object Oriented Programming: Unit II: Inheritance, Packages and Interfaces : Tag: : Definition, Concept, Syntax, Implementation, Example Java Programs - Multiple Inheritance
Object Oriented Programming
CS3391 3rd Semester CSE Dept | 2021 Regulation | 3rd Semester CSE Dept 2021 Regulation