inheritance3
inheritance3
inheritance in java
public Parent3(){ } public Parent3(String name1,String name2){ super(); this.name1=name1; this.name2=name2; System.out.println("this is base class"); } public double Circle(double pietop,double piedown,double r){ return((pietop/piedown)*r*r); } public int Rectangle(int length,int breadth ,int height){ return(length*breadth); } } package inheritance; public class Childclass3 extends Parent3{ public Childclass3(String name1,String name2){ super(name1,name2); //TODO Auto-generated constructor stub System.out.println("this is sub class"); } public int Rectangle(int length, int breadth,int height){ return length* breadth* height; } public static void main( String [] args){ Childclass3 Childclass3=new Childclass3("rana","dheer"); Parent3 p1=new Childclass3("dheer","rana"); Parent3 p3=new Parent3(); int value1=p1.Rectangle(10,30,40); System.out.println("Area of triangle" +value1); double value2=p3.Circle(22.0,7.0,4.0); System.out.println("Area of circle" +value2); System.out.println(Childclass3.name1); System.out.println(p1.name2); } } output program this is sub class this is base class this is sub class Area of triangle12000 Area of circle50.285714285714285 rana rana
Please send comments to
vgdarur.javafive@blogger.com
Copyright © 2008 - iForeRunner.com
http://www.iforerunner.com/