全书授课与教学课件28第04章.pdfVIP

  • 0
  • 0
  • 约1.49千字
  • 约 7页
  • 2023-11-20 发布于北京
  • 举报
【例】多态示例 class Animal { // 父类Animal int age = 10; public void eat() { System.out.println(动物吃东西); } public void shout() { System.out.println(动物在叫); } public static void run() { System.out.println(动物在奔跑); } } class Dog extends Animal { // 子类Dog 继承父类Animal, int age = 60; String name = 黑子; // 子类独有的属性name public void eat() { System.out.println(狗在吃东西); } public sta

文档评论(0)

1亿VIP精品文档

相关文档