• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extend & Implement ?

 
Gajanan Bandale
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is diff between extend and Implement keyword?
When one use extend or implement?
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
extend - use for inheritance
implements - use when your class is implementing interface.
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
extend - use for inheritance

<nitpick>implementing an interface is inheritance as well...</nitpick>

Extends is used to inherit from an abstract or concrete class. Implements is used to inherit an interface. Hope this helps...

Object-Oriented Programming Concepts
 
Joshua Smith
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, in Java a class can only extend one class, but a class may implement as many interfaces as it likes.
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also interface can extend only one interface
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, an interface can extend multiple interfaces.

Example:

[ August 25, 2005: Message edited by: Steve Morrow ]
 
Kalyana Sundaram
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Steve.
This is really an useful tip :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic