• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to find the base class  RSS feed

 
syruss kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

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().


Thanks in advance
 
Mauro Trevigno
Ranch Hand
Posts: 99
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Syruss,

http://docs.oracle.com/javase/specs/jls/se5.0/html/classes.html#228059

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.

Thanks & Regards,
Mauro
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Henry
 
syruss kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot henry and mauro
 
Robert Lippens
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!