Please look at the following code:
class Animal{
public void eat() throws Exception{
System.out.println("Here\'s the exception!");
}
}
class Dog extends Animal{
public void eat(){}
public static void main(
String args[]){
Animal a=new Dog();
Dog d=new Dog();
d.eat();
a.eat();
}
}
when i compile this, i get an unreported exception.. why's that so>? I know overriding in
java allows the overridden method in a subclass to either not declare any of the overriding method's exceptions or declare only a subtype of the declared exceptions and not declare new or broader unchecked exceptions. why's this behavior coming up? Please explain. Thanks in advance.