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

Pubblicato il: 04 luglio 2023
sul canale di: 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


In questa pagina del sito puoi guardare il video online Multi Level and Multiple Inheritance in Java || Lesson 40 || Java Programming || Learning Monkey || della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Wisdomers - Computer Science and Engineering 04 luglio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 182 volte e gli è piaciuto 4 spettatori. Buona visione!