Employeur impliqué
What is the difference between an abstract class and an interface in Java?
Utilisateur anonyme
I explained that both abstract classes and interfaces are used to achieve abstraction in Java, but there are key differences. An abstract class can have method implementations (concrete methods), constructors, and member variables, while an interface only contains abstract methods (until Java 8, when default and static methods were introduced). I also mentioned that a class can implement multiple interfaces, but it can only extend one abstract class. Additionally, I gave an example where an interface is preferable when multiple inheritance of type is required, and abstract class when sharing common code among related classes.