Multi Level and Multiple Inheritance in Java || Lesson 40 || Java Programming || Learning Monkey ||

Publié le: 04 juillet 2023
sur la chaîne: Wisdomers - Computer Science and Engineering
182
4

Multi Level and Multiple Inheritance in Java
In this class, We discuss Multi Level and Multiple Inheritance in Java.
The reader should have prior knowledge of inheritance in Java. Click Here.
We take an example and understand multi-level inheritance.
Example:
class A
{
int p;
void m1()
{
System.out.println(“First class “);
}
}
Class B extends A
{
int q=20;
void m2()
{
System.out.println(“second class”);
m1();
}
}
Class C extends B
{
int k =40;
void m5()
{
System.out.println(p);
m1();
}
}
More than one level of inheritance, we call multi-level inheritance.
Class C can use any of the members from class A or B.
class test
{
public static void main(string args[])
{
C ob = new C();
System.out.println(ob.p);
}
}
We create the object for class C.
Memory is allocated for all the instance variables in classes A, B, and C.
Multiple inheritance:
Java does not support multiple inheritances using classes.
One should understand the concept of multiple inheritance.
We have a class C which inherits classes A and B.
Class C extends A, B
One class can be inherited. Multiple classes can not be inherited in Java.

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 Multi Level and Multiple Inheritance in Java || Lesson 40 || 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 juillet 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 182 fois et il a aimé 4 téléspectateurs. Bon visionnage!