Interface vs Abstract Class

Posted on 2011-04-19
Last Modified: 2012-05-11
Generally when anyone says when or why do we use Interface instead of extending from class, the answer immideately given is Java doesn't support multiple inheritence hence we use interface. Some people say that it is bookish and the more better answer is if we do not have a clear idea about the code that goes into that function we frame the interface if not we can go for abstract class.

My question is if we do not have a clear idea about the functionality how come we could design the interface.
Question by:prsubject
    LVL 86

    Accepted Solution

    >>My question is if we do not have a clear idea about the functionality how come we could design the interface.

    It's not the functionality that's undecided and variable - it's the implementation
    LVL 20

    Expert Comment

    by:Amitkumar Panchal
    Agreed with CEHJ, it's an implementation.

    please refer for more understanding.
    LVL 92

    Assisted Solution

    You only need to specify the api to design your interface. You do not require a clear idea of the functionionality to achieve that, you just need to know what methods you need.
    LVL 86

    Expert Comment


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now