import java.io.*; class A { public void display() { System.out.println("SuperClass"); } } public class B extends A { @Override public void display() throws IOException { System.out.println("SubClass"); } }
Here, A is base class and B is derived class.
Now if method display() in class B throws IOException, it gives compile error.
It says, overridden method does not throw java.io.IOException. What does that mean?
But if it throws any other exception like ArithmeticException or NullPointerException, it works fine.
So, what is the problem??
Plzzz help.