Java语言编写代码
的有关信息介绍如下:代码如下/** * Author: zhyx * Date:2017/11/30 * Time:8:56 */public abstract class Contailner { double r; abstract double volume();}/** * Author: zhyx * Date:2017/11/30 * Time:8:57 */public class Cube extends Contailner { public Cube(double r) { this.r=r; } @Override double volume() { return r*r*r; }}/** * Author: zhyx * Date:2017/11/30 * Time:9:01 */public class Sphere extends Contailner { public Sphere(double r) { this.r=r; } @Override double volume() { return 4/3*Math.PI*r*r*r; }}/** * Author: zhyx * Date:2017/11/30 * Time:9:02 */public class Tiji { public static void main(String[] args) { Cube cube=new Cube(4); System.out.println("立方体体积为:"+cube.volume()); Sphere sphere= new Sphere(4); System.out.println("球体体积为:"+sphere.volume()); }}