• 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

keywords implements and extends

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are the key words different both are used to incorporate inheritance..why is there a difference???
 
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To put it simply extends is used to inherit other classes both abstract and non-abstract. implements is used in classes to inherit interfaces.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

implements is used in classes to inherit interfaces



You mean you will provide a legal implementation of the interface so that code outside your class can be sure that certain implementation of methods exist.
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Remko Strating:


You mean you will provide a legal implementation of the interface so that code outside your class can be sure that certain implementation of methods exist.



Yeah, I didn't like that when I wrote it, but couldn't think of a better answer at the time. Not all interfaces have methods defined, so perhaps a better explanation is when a class needs to use the implied contract of an interface.

And if an interface "inherits" another interface, extends is used.

[ August 08, 2007: Message edited by: David McCombs ]
[ August 08, 2007: Message edited by: David McCombs ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic