读书人

一道小弟我的考研题

发布时间: 2011-12-27 22:22:55 作者: rapoo

一道我的考研题
Using the example of "Payroll System Using Polymorphism " to create the example of Animal, Dog, and Cat by using Polymorphism, and to use one loop to make the cat and dog "Jiao " one time!

[解决办法]
多态嘛,animal是父类,有一个方法jiao(),cat dog继承animal,然后循环调用父类的jiao()
[解决办法]
java中没有多重继承,只有接口可以变相的实现,
public interfece Animal{}
public class dog extends Animal{}
public class cat extend Animal{}

读书人网 >J2SE开发

热点推荐