1.  >>  国开 / 面向对象程序设计
 国开 / 面向对象程序设计

interface Shape {

double area();

double girth();

}

class Rectangle implements Shape {

int a,b;

public Rectangle(int aa, int bb) {a=aa; b=bb;}

public double area() {return a*b;}

public double girth() {return 2*(a+b);}

}



public class XXK3 {

public static void main(String[] args) {

Shape x;

x=new Rectangle(5,8);

System.out.println(x.area()+", "+x.girth());

}

}
50.0, 36.0
40.0, 26.0
 参考答案:
 佳题速递: