I have the following code which has two interfaces which have two methods of the same name. However each method throws a different type of Exception.
public interface xyz {
void abc() throws IOException;
}
public interface qrs {
void abc() throws FileNotFoundException;
}
public class Implementation implements xyz, qrs {
// insert code
{ /*implementation*/ }
}
I know that in inheritance if a subclass method overrides a superclass method, a subclass's throw clause can contain a subset of a superclass's throws clause and that it must not throw more exceptions. However, I am not sure how exceptions are dealt with in interfaces.
For the implementation of the function abc() in the class Implementation, can this method throw both of the exceptions or just one? For example, is the following method valid?
public void abc() throws FileNotFoundException, IOException
Any insights are appreciated.