Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples Java
 

Multilevel Inheritance in Java


Code ResourceAuthor: Raju  

Difficulty Level:

Published: 4th Sep 2007   Read: 3390 times  

Filed in: Java
Add Comment


 


This is a multilevel inhertance in java where number of methods can be created and accessed any where in the class a1 in the main class is the new object. here class A is inherited by both B and C i and j can be accessed from the method lmn.

 


Sample Code
  1.  
  2. *multilevel inheritance*/
  3. class A
  4. {
  5.         int i=10,j=20;
  6.         void xyz()
  7.         {
  8.                 System.out.println(i+j);
  9.         }
  10.         void lmn()
  11.         {
  12.                 System.out.println("lmn");
  13.         }
  14. }
  15. class B extends A
  16. {
  17.         int k=40,l=45;
  18.         void abc()
  19.         {
  20.                 System.out.println(i+j+k);
  21.                 lmn();
  22.         }
  23. }
  24. class C extends B
  25. {
  26. }
  27. class Inherit
  28. {
  29.         public static void main(String args[])
  30.         {
  31.         C a1= new C();
  32.         a1.abc();
  33.         }
  34. }
  35.  
Copyright GeekInterview.com


Next Article: Inheritance in Java


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. iamdvr35752
2. venki_madesh30854
3. srinivasaraobora22480
4. bora_srinivasarao11729
5. Kiran.jakkaraju4609
6. parmod kumar duhan4502
7. chowsys3970
8. Venkateswara Rao3713
9. Raju3391
10. Vamshidhar Matam2290

Active Coders

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape