首页 > 编程语言 > 详细

java 继承与多态

时间:2016-10-23 20:46:24      阅读:238      评论:0      收藏:0      [点我收藏+]

技术分享

Example5_11.java

class  动物 {
   void cry() {
   }  
}
classextends 动物 {
   void cry() {
      System.out.println("汪汪....."); 
   }  
}
classextends 动物  {
   void cry() {
      System.out.println("喵喵....."); 
   }  
}
public class Example5_11 { 
   public static void main(String args[]) {
      动物 animal;
      animal = new 狗();
      animal.cry(); 
      animal=new 猫();
      animal.cry();
  }
}

 

java 继承与多态

原文:http://www.cnblogs.com/yihujiu/p/5990612.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!