父类的向上转型就是父类引用指向子类对象
public abstract class Animal { public abstract void eat(); }
public class Cat extends Animal { @Override public void eat() { System.out.println("cat eat fish"); } }
public class DemoMain { public static void main(String[] args) { // 编译看左,运行看右,父类引用指向子类对象就是向上转型 Animal an = new Cat(); an.eat(); } }