Multiple Inheritance Using Interfaces in Java || Lesson 64 || Java Programming || Learning Monkey ||

Publié le: 04 août 2023
sur la chaîne: Wisdomers - Computer Science and Engineering
3,387
54

Multiple Inheritance Using Interfaces in Java
In this class, We discuss Multiple Inheritance Using Interfaces in Java.
The reader should have prior knowledge of interfaces in Java. Click Here.
The concept of multiple inheritance is not allowed using class.
The below example shows the multiple inheritance using interfaces.
Example:
interface A
{
void m1();
void m2();
}
interface B
{
void m1();
}
class C implements A, B
{
public void m1()
{
System.out.println(“This is m1 method”);
}
public void m2()
{
System.out.println(“This is m2 method”);
}
}
class test
{
public static void main(String args[])
{
C ob = new C();
ob.m1();
}
}
In the above example, we have method “m1” in both interfaces.
But the implementation is done in class C.
We can use both extends and implements for a class.
The below examples show the use of both keywords.
Example:
interface A
{
void m1();
void m2();
}
interface B
{
void m1();
}
class C
{
void m5()
{
System.out.println(“this is class C”);
}
}
Class D extends C implements A, B
{
public void m1()
{
System.out.println(“This is m1 method”);
}
public void m2()
{
System.out.println(“This is m2 method”);
}
}
class test
{
public static void main(String args[])
{
D ob = new D();
ob.m1();
}
}

Link for playlists:
   / @wisdomerscse  


Link for our website: https://learningmonkey.in

Follow us on Facebook @   / learningmonkey  

Follow us on Instagram @   / learningmonkey1  

Follow us on Twitter @   / _learningmonkey  

Mail us @ learningmonkey01@gmail.com


Sur cette page du site, vous pouvez voir la vidéo en ligne Multiple Inheritance Using Interfaces in Java || Lesson 64 || Java Programming || Learning Monkey || durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Wisdomers - Computer Science and Engineering 04 août 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 3,387 fois et il a aimé 54 téléspectateurs. Bon visionnage!