Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Thursday, 23 February 2017

What is Mutilevel Inheritance In Java ?

Multilevel Inheritance :
Multilevel Inheritance

Multilevel Inheritance is derived from derived class ,means a subclass is inherited from another subclass as shown in above figure.
As per below program Class Pen inherits class Book and class Books inherits class Stationary, means class Books is parent class of class Pen and class Stationary is parent class of class Books, so in this case class Pen is inheriting all the properties of class Books and class Stationary ,this is called multilevel inheritance.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Stationary{
 void method_A(){
  System.out.println("Stationary CLass Method");
 }
}
class Books extends Stationary{
 void method_B(){
  System.out.println("Book CLass Method");
 }
}
class Pens extends Books{
 void method_C(){
  System.out.println("Pen CLass Method");
 }
}
public class MultilevelInheritanceExample {
 
 public static void main(String[] args) {
  Pens p = new Pens();
  p.method_A();
  p.method_B();
  p.method_C();
 }
}

Output:

Stationary CLass Method
Book CLass Method
Pen CLass Method


      
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



Share this Blog with yours Friends !!

No comments:

Post a Comment