• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can a class implement 2 different interfaces that have the same identical method?

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could somebody help me understand the logic behind implementing 2 interfaces that have identical methods?

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing is wrong with code. Code will compile and run successfully.
For explanation see page 257, Khalid Mughal 1.4, Question 6.15.

Pankaj Shinde
[ September 07, 2007: Message edited by: Pankaja Shinde ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rey leon:
Could somebody help me understand the logic behind implementing 2 interfaces that have identical methods? ...


I think the explanation you're looking for probably depends on what you perceive to be the issue.

"I" is an interface that says a method "m" will be available.

"I2" is an interface that says a method "m" will be available.

"T" is a class that implements both I and I2 by providing implementation for a method "m," and this satisfies the "contract" of both interfaces.

This overlap might make it difficult for T to satisfy the intent of m being in both interfaces (a situation that might be prevented through more descriptive method names). But beyond implementation, consider that an instance of T IS-AN I and IS-AN I2.
 
rey leon
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you both for your help! I really appreciate it. - L.
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic