问答详情
源自:10-3 Java 中的抽象类

关于抽象类课后思考

public class Circle extends Shape {

 float r=5.0f;

 

@Override

public float zhouchang() {

float zhouchang=3*2*r;

return zhouchang;

}


@Override

public float mianji() {

// TODO Auto-generated method stub

float mianji=3*r*r;

return mianji;

}

public void print(){

System.out.println("圆的周长为");

}


}

怎么样才能输出周长,

提问者:慕盖茨3009647 2018-05-19 11:47

个回答

  • qq_T_142
    2018-05-19 15:56:28

    在mian函数中定义

    Shape shape = new Circle();

    float i =  shape.zhouchang();

    System.out.println(i);