What is the difference between interface and abstract class?
Utilisateur anonyme
In Java, an abstract class are those declared as such (modified as abstract). It can contain implemented methods as well as abstract ones that should be implemented by concrete descending classes, as methods methods declared in interfaces. If an abstract class only has abstract methods it can be wrongly seen as equivalent of an interface but from an architectural point of view they are distinct since a class can only have one parent (abstract) class but, can implement multiple interfaces. Abstract classes have the advantage of being able of having methods with different visibility modifiers, such as private or protected, which aren't available to interfaces that can only declare public ones. From Java 8 interfaces can bring default and static implementations of methods and declaration of constants. Both, abstract classes and interfaces can receive anonymous implementations that would allow them to be instantiated.