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. Advertising

  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. Advertising

  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. 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. jakk
    Replies:
    4
    Views:
    12,512
  2. gaurav
    Replies:
    4
    Views:
    77,530
    vijay24805
    Apr 14, 2009
  3. Replies:
    1
    Views:
    802
    Ingo R. Homann
    Oct 26, 2005
  4. Daniel Pitts
    Replies:
    27
    Views:
    1,944
    Mike Schilling
    Feb 27, 2008
  5. tenxian
    Replies:
    4
    Views:
    285
    Mark Space
    Apr 27, 2008
Loading...

Share This Page