☕ Java
Beginner
What is the difference between abstract class and interface in Java?
Answer
An abstract class can have constructors, instance variables, and a mix of concrete and abstract methods. A class can extend only one abstract class. Use it when you want to share state and provide partial implementation among closely related classes. An interface cannot have constructors or instance state (only constants). A class can implement multiple interfaces. Use it to define a capability or contract for unrelated classes. Since Java 8, the distinction blurred with default methods in interfaces, but the key difference remains: abstract classes are for "is-a" relationships with shared state, while interfaces are for "can-do" capabilities without state.