Default Interface Methods. What is deep meaningful difference now, between abstract class and interface? [closed]

There is not a lot of difference between the two apart from the obvious fact that abstract classes can have state and interfaces cannot. Default methods or also known as virtual extension methods have actually been available in Java for a while. The main drive for default methods is interface evolution which means being able to add methods to an interface in future versions without breaking source or binary compatibility with existing implementations of that interface.

another couple of good points mentioned by this post:

  • The feature enables C# to interoperate with APIs targeting Android
    (Java) and iOs (Swift), which support similar features.
  • As it turns out, adding default interface implementations provides
    the elements of the “traits” language feature
    (https://en.wikipedia.org/wiki/Trait_(computer_programming)). Traits
    have proven to be a powerful programming technique
    (http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf).

Leave a Comment