• 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

Interface Implementation Issue

 
Greenhorn
Posts: 2
1
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, first time poster. I love this forum. In the following code snippet, why does the Phone3 class not have implement the doIt() method from the Device interface? I thought an implementing class must provide concrete implementations for the interface's methods.

Code:


Thanks in advance for your help.


Edit:
Nevermind. I managed to find my answer on the forum. Thanks a lot everyone. For future reference, the answer was:
Quote from Roel De Njs:


It can implement this method either directly (implementation defined in the class itself) or indirectly (implementation defined in a class it extends from).

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rayan Al-Hammami,

First of all, a warm welcome to CodeRanch!

Rayan Al-Hammami wrote:In the following code snippet, why does the Phone3 class not have implement the doIt() method from the Device interface? I thought an implementing class must provide concrete implementations for the interface's methods.


True (if the implementing class is not an abstract class)! But as you already have figured out yourself: a class can implement the method either directly (implementation defined in the class itself) or indirectly (implementation defined in a class it extends from).

Hope it helps!
Kind regards,
Roel

PS. Have a cow for searching this forum and answering your own question!
 
Rayan Al-Hammami
Greenhorn
Posts: 2
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Roel! That helps a ton, and yes, I shall continue answering my own questions when possible, to ensure you all can spend time on more important issues, haha. Thanks again!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic