class Fu { publicvoid show() { System.out.println("这是父类的show方法"); } } class Zi extends Fu { publicvoid show() { System.out.println("这是子类的show方法"); } publicvoid method() { System.out.println("这是子类的method方法"); } } class DuoTai{ publicstatic void main(String[] args) { Fu f = new Zi(); f.show(); Zi z = (Zi)f; z.method(); } }
|