This content has been marked as final. Show 3 replies
I have a class A. I would now like to make anotherWhy is that silly, if that's what you want?
class B that extends A.
The only difference between A and B is that B should
implement an interface that A does not implement.
I don't want the superclass A to implement this
interface it should only be implemented by the child
But it seems rather silly to make a class that only
contains "B extends A implements C".
The problem is that my super class A has an add method which does not throw any exception.
My subclass implements a remote interface where the same method throws a remote exception. I cannot override the superclass method a throw from the add method in class B.
The problem is that my super class A has an addIf the add method has the same semantics, then you can do it by having the subclass' add method not throw the exception. However, even with the same semantics, to methods with the same signature from two different parent types sounds like a recipe for confusion. And of course, if the two methods have different semantics, then you simply can't do it.
method which does not throw any exception.
My subclass implements a remote interface where the
same method throws a remote exception.
My advice is to change the name of one of the add methods. If you can't do that, then you'll have to find another approach.