difference between inheritance and interface?

Discussion in 'Java' started by syntax, Feb 11, 2004.

  1. syntax

    syntax Guest

    what is the difference between one level inheritance and one level
    implementation of interface ?

    i.e



    what is the difference between the following :


    class myclass extends abc
    {
    ....
    }

    AND

    class myclass implements interface_name
    {
    ....
    }
     
    syntax, Feb 11, 2004
    #1
    1. Advertisements

  2. syntax

    Ryan Stewart Guest

    "syntax" <> wrote in message
    news:...
    > what is the difference between one level inheritance and one level
    > implementation of interface ?
    >
    > i.e
    >
    >
    >
    > what is the difference between the following :
    >
    >
    > class myclass extends abc
    > {
    > ...
    > }
    >
    > AND
    >
    > class myclass implements interface_name
    > {
    > ...
    > }


    For an extensive discussion of class vs interface, see "abstract class
    versus interface" and "Design - inheritance vs interface" threads in
    comp.lang.java.programmer.
     
    Ryan Stewart, Feb 11, 2004
    #2
    1. Advertisements

  3. By implementing an interface, your object guarantees that the methods laid
    out in the interface will be implemented.

    By extending a base class (inheritance), you inherit from the base class
    public and protected instance methods and members. In other words, those
    methods and members are accessible from your new object.



    "syntax" <> wrote in message
    news:...
    > what is the difference between one level inheritance and one level
    > implementation of interface ?
    >
    > i.e
    >
    >
    >
    > what is the difference between the following :
    >
    >
    > class myclass extends abc
    > {
    > ...
    > }
    >
    > AND
    >
    > class myclass implements interface_name
    > {
    > ...
    > }
     
    Collin VanDyck, Feb 11, 2004
    #3
    1. Advertisements

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. jakk
    Replies:
    4
    Views:
    13,882
  2. gaurav
    Replies:
    4
    Views:
    77,785
    vijay24805
    Apr 14, 2009
  3. Replies:
    1
    Views:
    905
    Ingo R. Homann
    Oct 26, 2005
  4. Santa
    Replies:
    1
    Views:
    1,436
    Mark A. Odell
    Jul 17, 2003
  5. vishist
    Replies:
    3
    Views:
    481
    Tor Iver Wilhelmsen
    Oct 23, 2006
  6. tenxian
    Replies:
    4
    Views:
    443
    Mark Space
    Apr 27, 2008
  7. PerlFAQ Server
    Replies:
    0
    Views:
    551
    PerlFAQ Server
    Jan 6, 2011
  8. PerlFAQ Server
    Replies:
    0
    Views:
    475
    PerlFAQ Server
    Apr 15, 2011
Loading...