• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Implementing more than one interface  RSS feed

 
Ranch Hand
Posts: 765
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers.There is a bit confusion in my mind.Consider the following problem state.
Interface A has a method name getName() & Interface B has a method name getName().A class name implInterface implements A & B.Now how we can suggest that, which interface method implInterface has implemented.
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vikrama Sanjeeva:
Hi Ranchers.There is a bit confusion in my mind.Consider the following problem state.
Interface [b]A
has a method name getName() & Interface B has a method name getName().A class name implInterface implements A & B.Now how we can suggest that, which interface method implInterface has implemented.
Bye.
It doesnt matter which interface...
As long as your concrete class implement getMethod() its fine
A common implementation is sufficient...
Ragu
Viki.
[/B]


 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to JLS 8.1.4, it is permitted for a single method declaration in a class to implement methods of more than one superinterface.
If class implInterface has a method getName() that matches the methods in interfaces A and B, then it is considered to implement both.
For more details have a look at the examples given in JLS 8.1.4
 
Vikrama Sanjeeva
Ranch Hand
Posts: 765
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ravi.Tell me one thing that does this happens in real world application.?
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
 
Ranch Hand
Posts: 1245
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. Patterns is a good example...
if you want examples go to the OOA/D, UML, Patterns fourm!
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i came across this sort of a confusing aspect when i read book about C# :-)))). in C# too this kind of problem they address and right now dont slove it. but right, as Ragu said it really doesn't matter.
i tried to think in terms of practicality but in real world this couldn't happen i guess 'coz generally interfaces are designed by diff ppl in diff companies or environments and impelmentations are provided for those so that end users (in this case s/w developers) can use those things. but in that case they need some sort of ID to use it. e.g. in CORBA if two service providers have same interface methods that doesnt matter or affects as the user is going to know exactly what interface he/she wants to use providing "ID". and as far as implementation issue is concerned it's probably troublesome which interface u really want to implement but i don't think there are multiple interfaces that has same method signatures 'coz if that is the case we can have a super interface to both of those interfaces and work out things. and i dont think two interfaces will have same method signature if they are doing different things (still one cant guarentee) and if they are meant to do same thing we can have super interfaces as stated above.
i 've not come across any practical situation in which this happens.
regards
maulin.
 
Message for you sir! I think it is a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!