What’s the difference between abstract class and an interface

An abstract class is a class that may contain both abstract and concrete methods. It can have fields, constructors, and non-abstract methods. Subclasses of an abstract class must implement all abstract methods or be declared abstract themselves.

An interface, on the other hand, is a contract that specifies a set of methods that a class must implement. It cannot contain any concrete methods, fields, or constructors. A class can implement multiple interfaces but can only extend one class.

In summary, the main difference between an abstract class and an interface is that an abstract class can contain a mix of abstract and non-abstract methods, while an interface can only contain abstract methods. Additionally, a class can extend only one abstract class but can implement multiple interfaces.