What do you mean by 'Interface' & 'Abstract Base Class' ? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

What do you mean by 'Interface' & 'Abstract Base Class' ?

kishore_peddikishore_peddi Posts: 176Member

Hi,

Good day. Can you please explain what do you mean by 'Interface' and 'Abstract Base Class' and what are the differences between those two ?.

Advance ThanX for your time & patience.

Bye...
kishore

Comments

  • aveachaveach Posts: 5Member
    :
    : Hi,
    :
    : Good day. Can you please explain what do you mean by 'Interface' and 'Abstract Base Class' and what are the differences between those two ?.
    :
    : Advance ThanX for your time & patience.
    :
    : Bye...
    : kishore
    :
    :

    An interface is a specification that defines the methods that any class must have if it claims to implement that class. The interface states what an object of that type can do. FOr instance you may have noticed that many classes in java contain the words public class ... implements ActionListener, the ActionListener interface contains a set of methods( in this case it is only the actionPerformed method) that
    any class must have that wants to implement ActionListener. So if you see a class that implements ActionListener you know that this class has a actionPerformed method. Each class may implement the method differently, but we know, because of the interface, what to expect from any ActionListener object.
    interfaces do not provide any implementation details(i.e code for the methods, they just basically tell you the names of the methods you need and what they should do). Absract base classes are kind of the same but they would then have subclasses which provide implementation detail. For instance you might have an abstract base class called Animal. This class has no instances but the subclasses which would be specific animals would. You would not have an animal class without a sublcalss such as Dog.
Sign In or Register to comment.