关于继承需要注意哪些问题?
class Figure{
double dimension1,dimension2;
Figure(double x,double y)
{
dimension1=x;
dimension2=y;
}
double area()
{
System.out.println("Area not defined");
return 0;
}
}
class Rectangle extends Figure
{
double l,h;
Rectangle (double x,double y)
{
super (x,y);
l=x;
h=y;
}
double area()
{
System.out.println("Area of a Rectangle");
return l*h;
}
}
class Square extends Figure
{
double l;
Square (double x);
{
super (x);
l=x;
}
double area()
{
System.out.println("Area of a Square");
return l*l;
}
}
class Area
{
public static void main(String [] args)
{
Figure fig=new Figure(2,5);
Rectangle rect=new Rectangle(3,5);
Square sq=new Square (4);
System.out.println(rect.area());
System.out.println(sq.area());
}
}
还有帮我看看这程序都哪错了啊?