第1个回答 推荐于2018-04-12
一楼有误,抽象父类Shape中的方法area()应为抽象的,改为:
public abstract double area(); //抽象方法求面积
还有,变量使用前要先赋值,可在构造器中,如类Rectangle :
public Rectangle(double width,double height){
this.width = width;
this.height = height;
}
当然,也可以在其它地方赋值,如:setter()方法,本回答被提问者和网友采纳