Code.GeekInterview.com
 
 

Java Code Base

 
Code Samples Java
 

Inheritance in Java


Code ResourceAuthor: Raju  

Difficulty Level:

Published: 4th Sep 2007   Read: 4076 times  

Filed in: Java
Add Comment


 

 

Sponsored Links


 

 

This program comprises of using a inhertance in java as shown in the program. A is the class, B is the another class. class A is inherited by the class B.

 


Sample Code
  1.  
  2. INHERITANCE
  3. class A
  4. {
  5.         int i=10,j=20;
  6.         void abc()
  7.         {
  8.                 System.out.println("abc");
  9.         }
  10.        
  11. }
  12. class B extends A
  13. {
  14.         int k;
  15.         void xyz()
  16.         {
  17.                 System.out.println("xyz");
  18.         }
  19. }
  20. class Display1
  21. {
  22.         public static void main(String args[])
  23.         {
  24.                 B a1= new B();
  25.                 a1.abc();
  26.         }
  27.        
  28. }
  29.  
Copyright GeekInterview.com


Next Article: Creating objects 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    



Popular Coders

# Coder NameHits
1. srinivasaraobora130594
2. iamdvr97637
3. venki_madesh35132
4. Raju18459
5. parmod kumar duhan15743
6. Kiran.jakkaraju14037
7. chowsys7450
8. Venkateswara Rao6469
9. ashish.cns6342
10. Vamshidhar Matam5424

Active Coders

Refined Tags