Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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.
 
Forget Steve. Look at this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic