🐦 Kotlin Beginner

What is an interface in Kotlin?

Answer

A Kotlin interface defines a contract of methods and properties that implementing classes must provide. Unlike abstract classes, interfaces cannot hold state (no backing fields for properties) and cannot have constructors. However, they can provide default method implementations, which classes can optionally override. A class can implement multiple interfaces. Interfaces with default implementations are compiled to Java 8 default interface methods on the JVM. Use interfaces when you want to define a capability that multiple unrelated classes can share.