3 ms·
With the ability to add static methods and default implementations to an interface, what is now the practical difference between that and an abstract class?
by davesims 14y ago
With the ability to add static methods and default implementations to an interface, what is now the practical difference between that and an abstract class?
- logn 14y agomultiple inheritance?
- alrex021 14y agoInterfaces with the addition of default methods, in contrast to abstract classes, provide the inheritance of behaviour (but not state) from multiple sources.
- danieldk 14y ago- A class can only inherit from one abstract class, but can implement multiple interfaces. - An interface cannot have member variables.
- twic 14y agoAlso, an abstract class can have a constructor (and instance initializers, and initialization expressions for its fields), which an interface can't. That means an abstract class can do work when it is created. Although it's probably a good idea not to do too much work - a factory method would be better for that.
- iso8859-1 14y agoDid you read the article? Try again, search for "Why abstract classes can't be instantiated using a lambda".