package com.imooc;public class Dog extends Animal { public void eat(){ System.out.println("狗是吃肉的"); } public void watchDoor(){ System.out.println("狗具有看门的能力"); }}package com.imooc;public class Initail { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Animal obj1 = new Animal(); Animal obj2 = new Dog();//父类指向子类 Animal obj3 = new Cat(); obj1.eat(); obj2.eat(); obj3.eat(); ——————? }}
添加回答
举报
0/150
提交
取消