Explain the difference between an abstract class and an interface in Java.
TechnicalSoftware DeveloperJava DeveloperBackend DeveloperSenior developer JavaSenior Java DeveloperSoftware EngineerAn abstract class can have both abstract methods and concrete methods, allowing for shared code among subclasses. It can also have member variables and constructors. In contrast, an interface can only declare methods (prior to Java 8) and does not provide any implementation, promoting a strict contract for implementing classes.
Additionally, a class can extend only one abstract class but can implement multiple interfaces, which provides greater flexibility in design.