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

Published: 04 July 2023
on channel: 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


On this page of the site you can watch the video online Multi Level and Multiple Inheritance in Java || Lesson 40 || Java Programming || Learning Monkey || with a duration of hours minute second in good quality, which was uploaded by the user Wisdomers - Computer Science and Engineering 04 July 2023, share the link with friends and acquaintances, this video has already been watched 182 times on youtube and it was liked by 4 viewers. Enjoy your viewing!