Now you tell, which is overridden by the ObjectTest class?
I guess, neither of them :-), both are only implemented.
By implementing interface you are saying, that you guarantee, that your class will have methods _compatible_ with those specified in interface. Why am I saying compatible? Because you can narrow exceptions. (Increasing visibility make no sense, they are already public)
Why are we seeing those compile-errors? Because compiler checks for checked exceptions at compile time based on type you provided at compile time. There is no guarantee, that exceptions will be not thrown, because child is not throwing them. Compiler doesn't know.
nik: ObjectClass implements both interfaces with one method that conforms both interfaces. There is only one method. (at contrast to C++ multiple inheritance, where you might get in some trouble)
Joined: Feb 28, 2007
I agree, the term overriding is not usable in case of interface implementation. It is the contract between class and interface that the class will give the definition (implementation) of the interface methods with proper signature, that is public accessibility and not declaring any broad checked exception to be thrown.
I take compatibility in the terms that the exception the implementing class declares for the interface method must be compatible with all the interfaces it implements (in case more than one interfaces have the same method name and signature)
Obviously this does not apply with non-checked exceptions.
I agree, the term overriding is not usable in case of interface implementation. [ May 08, 2007: Message edited by: Chandra Bhatt ]
I think, I said that before thinking about it properly.
Seems, that overriding is usable term. (Interface is just a pure abstract class)
Joined: May 04, 2007
It is legal to throw descendant of exception. (can be safely upcasted) [ May 08, 2007: Message edited by: John Stone ]
Joined: Feb 28, 2007
What I get from overriding is polymorphic call of methods, run time decision which method to select on behalf of the object the reference variable referring to.
What I see in the code example (I posted some posts above), that it only matters what reference variable you are using to call the interface methods. ref type decides whether you must declare or handle the exception declared to be thrown by the interface method. But if you have implemented that interface without declaring that exception(checked) what the interface says to be, still you have to declare or handle it because you are using interface ref variable to call that method (it is the time compiler bothers you).
So far as implementing and overriding terms are considered, both are used interchangeably but has difference. Overriding means the JVM at run time, could choose your overridden method, not the inherited from the parent hence polymorphism the most liked thing or OOP as I think.