It is permitted for a single method declaration in a class to implement methods of more than one superinterface. For example, in the code:
The method getNumberOfScales in class Tuna has a name, signature, and return type that matches the method declared in interface Fish and also matches the method declared in interface Piano; it is considered to implement both.
syruss kumar wrote:
I tried to understand the concept of inheritance. below is the scenario please help me to understand better.
Can you please tell me from which interface is called while calling displayName().
Well, since interfaces don't have an implementation, I am assuming that you meant to ask ... when the InterfaceTest class implements the displayName() method, which interface's contract is it satisfying? Or from which interface is the implementation for? The answer is both.
As long as your subclass has the same methods presented in the interfaces, you've successfully implemented them. If InterB had another method called, for instance, hideName(); your current code would only fulfill one of the interfaces, not both.