class AA{
public void test() throws IOException{
System.out.println("In AA’s test()");
}}
class BB extends AA{
public void test () throws FileNotFoundException{
System.out.println("In BB’s test()");
}
}
class CC extends AA{
public void test () throws Exception{
System.out.println("In CC’s test()");
}
}
子类的重写方法抛出的异常不能比父类还要大 Exception 是IOException 的父类 会报错
class AA{
public void test() throws IOException {
System.out.println("In AA’s test()");
}}
class BB extends AA{
@Override
public void test () throws FileNotFoundException {
System.out.println("In BB’s test()");
}
}
class CC extends AA{
@Override
public void test () {
System.out.println("In CC’s test()");
}
}