simple inheritance
simple inheritance
/** * */ package com.training; /** * @author arun * */ public class A { int a; float b; void Show(){ System.out.println("b in super class: " + b); } } /** * class2 */ package com.training; /** * @author arun * */ class B extends A{ int a; float b; B( int p, float q){ a = p; super.b = q; } void Show(){ super.Show(); System.out.println("b in super class: " + super.b); System.out.println("a in sub class: " + a); } public static void main(String[] args){ B subobj = new B(1, 5); subobj.Show(); } } /*output b in super class: 5.0 b in super class: 5.0 a in sub class: 1 */
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/