Code.GeekInterview.com
 
 

Java Code Base

 
Code Samples Java
 

Multilevel Inheritance


Code ResourceAuthor: parmod kumar duhan  

Difficulty Level:

Published: 13th Sep 2007   Read: 20902 times  

Filed in: Java
Add Comment


 

 

Sponsored Links


 

 

It is the enhancement of the concept of inheritance. When a subclass is derived from a derived class then this mechanism is known as the multilevel inheritance. The derived class is called the subclass or child class for it's parent class and this parent class works as the child class for it's just above ( parent ) class. Multilevel inheritance can go up to any number of level.

 


Sample Code
  1.  
  2. class A
  3. {  int x;  int y;  
  4. int get(int p, int q)
  5. {    x=p; y=q;
  6. return(0);  
  7.  }
  8.    void Show()
  9. {      System.out.println(x);    
  10.  }
  11. }
  12. class B extends A
  13. {  void Showb()
  14. {    System.out.println("B");    
  15. }
  16. }
  17. class C extends B
  18. {  void display()
  19. {    System.out.println("C");
  20.  }  
  21. public static void main(String args[]){    A a = new A();    a.get(5,6);    a.Show();    }}
  22. }
Copyright GeekInterview.com


Next Article: Multilevel Inheritance in Java


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

you do not close the class why?
Comment posted by: tariq on 2010-05-11T02:05:08

Popular Coders

# Coder NameHits
1. srinivasaraobora244835
2. iamdvr139542
3. venki_madesh38730
4. Raju31576
5. Nidhi Saxena26086
6. Kiran.jakkaraju23674
7. parmod kumar duhan20903
8. yuvanmytri17304
9. venkat_kiran13089
10. chowsys11438

Active Coders

Refined Tags