// 此程序依据的原理是子类对象即是父类对象
class EatException extends Exception {
}
class Father {
public void eat() throws EatException {
System.out.println("father eat");
throw new EatException();
}
}
class son extends Father {
public void eat() throws Exception {
System.out.println("son eat");
throw new Exception();
}
}
public class TestOverride {
public static void main(String[] args) {
Father father=new Father();
try {
father.eat();
} catch (EatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}