• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to find the base class

 
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
 
Ranch Hand
Posts: 99
Tomcat Server Java Linux
  • 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
 
author
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux 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
 
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.
 
    Bookmark Topic Watch Topic
  • New Topic