abstract class figure
{
double dim1;
double dim2;
abstract double area();
void figure1(double a,double b)
{
dim1=a;
dim2=b;
}
}
class rectangle extends figure
{
rectangle(double a,double b)
{
super.figure1(a,b);
}
double area()
{
System.out.println("inside area of rectangle");
return dim1*dim2;
}
}
class triangle extends figure
{
triangle(double a,double b)
{
super.figure1(a,b);
}
double area()
{
System.out.println("inside area of triangle");
return (dim1*dim2)/2;
}
}
class absfig4
{
public static void main(String args[])
{
rectangle r=new rectangle(10,30);
triangle t=new triangle(10,50);
System.out.println("area of rectangle "+r.area());
System.out.println("area of triangle "+t.area());
}
}
Subscribe to:
Post Comments (Atom)
MY HIT COUNTER
Blog Archive
-
▼
2009
(38)
-
▼
November
(27)
- few programs on bank project
- customer identification number
- bank programs
- min balance program in oracle
- cards balance
- real time programs in bank project
- real time registration example
- Creation of tables in oracle
- practice quries
- quries
- reverse number
- throws exception
- throws exception
- divide by zero
- array index
- length of a string name
- no parameters to string
- print two parameters
- abstract class in core java
- inside area of rectangle
- area of rectangle
- three string parameters
- class b extends a
- incremeting numbers
- sum of three parameters
- box program
- strings
-
▼
November
(27)
Custom Search
No comments:
Post a Comment