//多态性实例 class 动物 { void cry() {} } class 狗 extends 动物 { void cry() { System.out.println("汪汪旺旺"); } } class 猫 extends 动物 { void cry() { System.out.println("喵喵喵喵"); } } public class text { 动物 ani; ani = new 狗(); ani.cry(); ani = new 猫(); ani.cry(); }