Professional Documents
Culture Documents
// child class
public static void main(String[] args) {
class Rectangle extends Geometry{
Circle circle1=new Circle(5.0);
int l,w,h;
Circle circle2=new Circle("green");
Rectangle (int l,int w,int h) {
System.out.println("the area of the circle ="+circle1.getarea());
this.l=l;
System.out.println("the color of the circle is "+circle2.getcolor());
this.h=h;
System.out.println("the date of circle is created on "+circle1.getdate());
this.w=w;
Rectangle rectangle1=new Rectangle(12,4,23);
}
Rectangle rectangle2=new Rectangle ("yellow");
Rectangle(String color) {
System.out.println("the area of the rectangle ="+rectangle1.getarea());
setcolor(color); // super class method
System.out.println("the color of the rectangle is "+rectangle2.getcolor());
}
System.out.println("the date of rectangle is created on " +rectangle1.getdate());
int getarea() {
}
return l*w*h;
}
}
double getarea() { }
return raduis*raduis*Math.PI;
String getcolor() {
}
return color;
}
}
Date getdate() {
}
public class Access {
else
m(circle1);
m(rectangle1);
m(rectangle2);
}
Out put
the area of the circle = 78.53981633974483