Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2012
    Location
    Mumbai
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Interfaces in JAVA

    What is the use of Interfaces in Java? Multiple Inheritance only!! I don't think so......Can someone explain me what were the many reasons for interfaces coming in existence

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Its a contract. Objects declared as an interface guarantee that they will contain the methods contracted by that interface. Since Java does not support multiple extends, interfaces are used to perform multiple inheritance, and because of the lack of multiple extends, interfacing is far more valuable in Java than extends ever will be.
    So yes, short version would be that interfaces are used for multiple inheritance as it allows you to interpret a single class as multiple datatypes.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •