Implement interface

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Johansson

    #1

    Implement interface

    Hello!

    When a class implaments an Interface must the class implement all methods?
    Whan happen if the class don't implament all methods in the interface. Will
    it cause compile error then.

    //Tony


  • Murray

    #2
    Re: Implement interface


    "Tony Johansson" <johansson.ande rsson@telia.com > wrote in message
    news:4Eome.1387 57$dP1.488907@n ewsc.telia.net. ..[color=blue]
    > Hello!
    >
    > When a class implaments an Interface must the class implement all methods?
    > Whan happen if the class don't implament all methods in the interface.[/color]
    Will[color=blue]
    > it cause compile error then.
    >
    > //Tony[/color]

    Why don't you try it and find out yourself?

    A class must implement all methods of the interface, unless the class is
    declared as abstract.


    Comment

    • James McIninch

      #3
      Re: Implement interface

      <posted & mailed>

      Tony Johansson wrote:
      [color=blue]
      > Hello!
      >
      > When a class implaments an Interface must the class implement all methods?[/color]

      Yes, that's the idea.

      [color=blue]
      > Whan happen if the class don't implament all methods in the interface.
      > Will it cause compile error then.[/color]

      It doesn't compile.
      [color=blue]
      >
      > //Tony[/color]

      --
      Remove '.nospam' from e-mail address to reply by e-mail

      Comment

      • Gordon Beaton

        #4
        Re: Implement interface

        On Sun, 29 May 2005 19:22:40 GMT, Tony Johansson wrote:[color=blue]
        > When a class implaments an Interface must the class implement all
        > methods? Whan happen if the class don't implament all methods in the
        > interface.[/color]

        You have two choices:

        - implement every method required by the interface

        or

        - declare the missing methods abstract in your class. This forces you
        to declare your class abstract and, as a result, forces you to
        subclass the class (and implement the missing methods) before you
        can create any objects.
        [color=blue]
        > Will it cause compile error then.[/color]

        Otherwise, yes.

        /gordon

        --
        [ do not email me copies of your followups ]
        g o r d o n + n e w s @ b a l d e r 1 3 . s e

        Comment

        Working...