예외전가
2012-02-13
|
by rlfcksdud
1980
class A {
void foo()throws Exception {
System.out.println("A");
throw new Exception();
}
}
class Sub2 extends A {
void foo(){
System.out.println("B");
}
}
class Tester
{
public static void main(String[] args)
{// main에서 throws Exctpion ?
A a = new Sub2();
a.foo();
}
}
====
a.foo()면 sub2의 메소드 호출인데 부모클래스에서 예외전가를 메인에서 왜 잡아줘야 하죠?