Problem Statement
How do interfaces work in Kotlin and how do they differ from abstract classes?
Explanation
Kotlin interfaces can contain abstract method declarations, default implementations using method bodies, and property declarations which must be abstract or have custom accessors, declared with interface keyword. Unlike Java 8 interfaces, Kotlin interfaces can have properties but cannot store state meaning no backing fields, and classes implement interfaces using colon syntax like class MyClass colon MyInterface.
Interfaces differ from abstract classes in that a class can implement multiple interfaces but inherit from only one abstract class, interfaces cannot have constructors or stored properties with backing fields, and abstract classes can have state and initialization blocks. Both can have abstract and concrete methods, but interfaces are preferred when defining contracts without implementation or when you need multiple inheritance of type.
Use interfaces for defining capabilities or contracts like Clickable, Serializable, or Repository where implementations might vary widely, and abstract classes for modeling is-a relationships with shared code and state. Kotlin's interface properties and default implementations make interfaces more powerful than Java interfaces while maintaining the multiple inheritance benefits that abstract classes cannot provide.
