• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

One class implement two interfaces with common methods??

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Two interfaces have same methods.
one class implements both interfaces.
Is any problem in this? How will we distinguish the methods?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem.

Why you need to distingush methods from these two interfaces ? Because there is no implementation in the interface so would it make any sense distingushing these two itnerfaces.
 
Hemant Agarwal
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But .NET is distinguishing why?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No idea about .NET ... does the method implementation specify which interface it is for? But in Java the logic is fairly simple.

Interface A says the implementer must have method x(). Interface B says the implementer must have method x(). If you have method x() the syntax is good and you have satisfied the compiler's checking for both interfaces.

If the documentation for interface A says x() increments the x coordinate and the doc for B says it decrements the x coordinate, the semantics are inconsistent and some client of your class will be unhappy.

So there can be cases where implementing two interfaces with matching method signatures is possible, but not correct. If .NET matches the method implementation to the interface they might get around this issue.
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic