Friend of mine said that not every interface is abstract. I haven't chance to discuss that with him but it get me thinking of not abstract interface in any type of language.
Is there a non abstract interfaces?
|show 1 more comment|
Simple answer to your question : No, your friend is wrong.
An interface provides no implementation of the methods it defines. Would it make sense if we could instantiate one of those? Of course not. Interfaces are only that, an abstraction.
This is obviously assuming that when you say
The idea of an interface (ie, a description of facilities provided and their semantics) is inherently abstract.
However, the question appears to confuse this with the mechanism by which such an interface (small i) may be reified into certain languages which provide an
Further, there is anyway more than one thing you may wish abstract:
Depends much on what meaning your friend gave to the word interface.
Interface as the concept of an abstract contract on methods/properties
So this means the Interface types provided by diverse languages (like the cited above: C#, Object Pascal (Delphi or FPC), Java, etc) so the answer is no.
In this case, the Interface is an contract on methods - without any form of implementation.
Interface as a contract on the description of facilities provided and their semantics
In this case, even an non-pure abstract class can be considered an interface. In this case, the designer even have how to implement default basic behavior (like throwing exceptions on non-implemented virtual methods which are not abstract) on that base class.
So, if it is the case, so yes those "interfaces" can be not abstract.
Interface from simple definition is abstraction of API that class can implement. If it is not abstract, then it is not an interface.
Interfaces need not be abstract. Example:
All above answers are correct. But this is how I understand it.
E.g. An Interface could be to book a ticket. You could then have various entities that provide you this service. A travel agent, online booking, or actual airline office.
They all provide the service (