a few java questions

Discussion in 'OT Technology' started by D1G1T4L, Sep 20, 2006.

  1. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    Havent done java in a while so I have a few questions

    Is it possible to extend an interface? (interface is basically a class so you should be able to do it I think?)
    you can only implement interfaces right?
     
  2. tyrionlannister

    tyrionlannister New Member

    Joined:
    Jun 13, 2006
    Messages:
    710
    Likes Received:
    0
    Location:
    New York
    Yes, you can extend them

     
  3. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area
    It says an interface can extend an interface
    but can a class extand an interface?
     
  4. Coottie

    Coottie BOOMER......SOONER OT Supporter

    Joined:
    Jun 6, 2006
    Messages:
    32,407
    Likes Received:
    0
    Location:
    OKC
    I thought interfaces were just undefined methods and any definition you provide could be considered "extending the interface" ...but we're just starting to talk about them in class so I could be wrong.

    I do know that you can't have stand alone methods is Java, everything must be contained in a class.
     
  5. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    A class implements an interface. To do what you want, you would extend an interface and then implement it in your class. Of course, classes are able to implement interfaces differently.

    You should read up on the "Extension Object Pattern" to learn about how to pull interesting shenanigans with interfaces.
     
  6. D1G1T4L

    D1G1T4L Active Member

    Joined:
    May 4, 2001
    Messages:
    16,489
    Likes Received:
    0
    Location:
    Bay Area

    so its possible to extend an interface class then right? but you just have to provide definition for every method
     
  7. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    One interface can extend another. And no, you don't have to redefine every method.
     

Share This Page