当前位置: 代码迷 >> J2SE >> 一道小弟我的考研题
  详细解决方案

一道小弟我的考研题

热度:79   发布时间:2016-04-24 15:10:11.0
一道我的考研题
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{}
  相关解决方案