Interface/Exception Question
I just thought about this and wonder if i am right:
public interface Abc()
{
doinSmth();
}
public class Cde() implements Abc
{
doinSmth() //throws Exception won't work, got to catch it
{
// code that throws exception
}
}
public class Unknown(Abc cde_instance)
{
// doinSmth is used here
}
Because cde is used in Unknown as Abc and Abc doesn't throw
Exception, Cde is not allowed to throw it. That means all Exceptions
got to be catched in Cde. Right?
[569 byte] By [
mischka24] at [2007-9-27 22:34:54]

Cde can throw an excpetion... but, a method in Cde that is overriding a another method (in this case doinSmith() from Abc) that does not throw an exception, the method cannot throw an excpetion either. When overriding a method, the parameter list must be the same as the method it is overriding, the method cannot be more private than the method it is overriding, the return type must be the same, and any exceptions throw by that class must be of the same class or a subclass of the same class that is throw by the parent method.