摘要: abstract class Geometry{public abstract double getArea();}class Pillar{Geometry bottom;double height;Pillar(Geometry bottom,double height){this.bottom=bottom;this.height=height;}void changeBottom(Geometry bottom){this.bottom=bottom;}public double getVolume(){return bottom.getArea()*height;}}class La 阅读全文
posted @ 2013-04-14 21:22 徐慧同学 阅读(143) 评论(0) 推荐(0) 编辑
摘要: class Animal{void cry(){}}class Dog extends Animal{void cry(){System.out.println("Wang!Wang!...");}}class Cat extends Animal{void cry(){System.out.println("miao~~~~miao~~~~");}}public class Example5_9{public static void main(String args[]){Animal animal;animal=new Dog();animal.cr 阅读全文
posted @ 2013-04-14 20:58 徐慧同学 阅读(182) 评论(0) 推荐(0) 编辑
摘要: class A{double n;int m;void f(){System.out.printf("子类继承方法f(),n=%f,m=%d\n",n,m);}void g(){System.out.printf("你好,n=%f,m=%d\n",n,m);}}class B extends A{int n=12;void g(){System.out.printf("子类重写方法g(),n=%d,m=%d\n",n,m);}void cry(){System.out.printf("子类新增的方法,n=%d,m=%d\n& 阅读全文
posted @ 2013-04-14 20:49 徐慧同学 阅读(136) 评论(0) 推荐(0) 编辑