implement or extend?

Discussion in 'Java' started by _.-=, Jul 28, 2003.

  1. _.-=

    _.-= Guest

    Hi!

    Whats the difference between "implements" and "extends"?

    Thanks to all.

    -ReAdY-
     
    _.-=, Jul 28, 2003
    #1
    1. Advertising

  2. _.-=<[ { E v E r E a d y } ]>=-._ wrote:

    > Whats the difference between "implements" and "extends"?


    "implements" is for interfaces; "extends" is for classes.
    Please look at the Java Tutorial on java.sun.com for an
    explanation of classes and interfaces.

    <http://java.sun.com/docs/books/tutorial/java/index.html>

    --
    Manish Jethani (manish.j at gmx.net)
    phone (work) +91-80-51073488
     
    Manish Jethani, Jul 29, 2003
    #2
    1. Advertising

  3. _.-=<[ { E v E r E a d y } ]>=-._ wrote:

    > Hi!
    >
    > Whats the difference between "implements" and "extends"?
    >
    > Thanks to all.
    >
    > -ReAdY-
    >
    >


    Well, you implement interfaces and you extend classes. You can only
    extend one class in java, but you can implement many interfaces.
    --
    Daniel Sjöblom
     
    =?ISO-8859-1?Q?Daniel_Sj=F6blom?=, Jul 29, 2003
    #3
  4. _.-=

    Roedy Green Guest

    Roedy Green, Jul 29, 2003
    #4
  5. _.-=

    _.-= Guest

    Since no one happened to answer my question, I thought I'd answer it myself
    now that I've figured it out.

    When you "extend" a class, any methods that you write with the same name
    will override the parent class' method.

    When you "implement" a class, the parent class had nothing more than the
    method definition (i.e. there was no code in the method) so, in effect, all
    you are doing is adding your own method code to what was just a method
    declaration and therefore not overriding the parent methods.

    Hope it helps anyone else who was looking for an answer to the same
    question.

    -EvErEady

    "_.-=<[ { E v E r E a d y } ]>=-._" <> wrote in message
    news:bg5b1f$...
    > Hi!
    >
    > Whats the difference between "implements" and "extends"?
    >
    > Thanks to all.
    >
    > -ReAdY-
    >
    >
     
    _.-=, Jul 30, 2003
    #5
  6. Daniel Sjöblom <_NOSPAM> writes:

    > Well, you implement interfaces and you extend classes.


    Except interfaces which may extend interfaces.
     
    Tor Iver Wilhelmsen, Jul 30, 2003
    #6
  7. "_.-=<[ { E v E r E a d y } ]>=-._" <> scribbled the following:
    > Since no one happened to answer my question, I thought I'd answer it myself
    > now that I've figured it out.


    "No one happened to answer your question"? Then what do you call the
    four answers you got from various people?

    --
    /-- Joona Palaste () ---------------------------\
    | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
    | http://www.helsinki.fi/~palaste W++ B OP+ |
    \----------------------------------------- Finland rules! ------------/
    "I will never display my bum in public again."
    - Homer Simpson
     
    Joona I Palaste, Jul 30, 2003
    #7
  8. Joona I Palaste wrote:

    > "_.-=<[ { E v E r E a d y } ]>=-._" <> scribbled the following:
    >
    >>Since no one happened to answer my question, I thought I'd answer it myself
    >>now that I've figured it out.

    >
    >
    > "No one happened to answer your question"? Then what do you call the
    > four answers you got from various people?


    I think he meant that no one seemed to have given a satisfactory
    answer. And after seeing his answer, I think I'll agree. He
    gave a more complete answer to his own question.

    But Java is now old enough that people will not answer basic
    questions like the difference between "implements" and "extends".

    Manish

    --
    Manish Jethani (manish.j at gmx.net)
    phone (work) +91-80-51073488
     
    Manish Jethani, Jul 30, 2003
    #8
  9. _.-=

    Roedy Green Guest

    On Wed, 30 Jul 2003 13:36:03 +0400, "_.-=<[ { E v E r E a d y }
    ]>=-._" <> wrote or quoted :

    >Since no one happened to answer my question, I thought I'd answer it myself
    >now that I've figured it out.


    I saw four answers posted before yours. Be careful not to insult the
    hand that feeds you.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Aug 1, 2003
    #9
  10. Manish Jethani <> writes:
    > But Java is now old enough that people will not answer basic
    > questions like the difference between "implements" and "extends".


    No, we have a special group for such basic questions:

    comp.lang.java.help

    /Thomas
     
    Thomas Weidenfeller, Aug 1, 2003
    #10
  11. _.-=

    Adam Maass Guest

    "_.-=<[ { E v E r E a d y } ]>=-._" <> wrote:
    > Since no one happened to answer my question, I thought I'd answer it

    myself
    > now that I've figured it out.
    >
    > When you "extend" a class, any methods that you write with the same name
    > will override the parent class' method.
    >
    > When you "implement" a class, the parent class had nothing more than the
    > method definition (i.e. there was no code in the method) so, in effect,

    all
    > you are doing is adding your own method code to what was just a method
    > declaration and therefore not overriding the parent methods.
    >


    You can't implement a class. You can only implement an interface.

    What is an interface? It looks an awful lot like an abstract class where all
    the methods are themselves abstract.

    -- Adam Maass
     
    Adam Maass, Aug 1, 2003
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yuriy

    How to Extend Session time

    Yuriy, Oct 16, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    9,724
    Bratislav Jevtic
    Oct 17, 2003
  2. Yuriy

    How to extend Session?

    Yuriy, Oct 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    1,290
    Lei Guangfu
    Oct 17, 2003
  3. Steve - DND

    Can you extend HtmlControls?

    Steve - DND, May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    999
    Natty Gur
    May 18, 2004
  4. =?Utf-8?B?ams=?=
    Replies:
    6
    Views:
    668
    =?Utf-8?B?ams=?=
    Dec 24, 2004
  5. Replies:
    2
    Views:
    648
    Roedy Green
    Dec 12, 2005
Loading...

Share This Page