Declaration and Implementation
Interfaces are declared using theinterface keyword. By default, all members are public and open. A class or object implements an interface using the : operator and must provide implementations for all abstract members using the override modifier.
Interface Properties
Properties declared in an interface can either be abstract or provide implementations for their accessors (get / set). Because interfaces cannot hold state, properties cannot be initialized directly, nor can they utilize a field identifier (backing field).
Resolving Overriding Conflicts
When a class implements multiple interfaces that contain methods with identical signatures and default implementations, the compiler mandates that the implementing class explicitly override the conflicting method. Thesuper<InterfaceName> syntax is used to invoke specific interface implementations.
Interface Inheritance
Interfaces can inherit from one or multiple other interfaces. A derived interface can declare new members, provide default implementations for inherited abstract members, or override inherited properties. Classes implementing the derived interface are only required to implement the remaining abstract members.Functional (SAM) Interfaces
An interface with exactly one abstract method is known as a Functional Interface or a Single Abstract Method (SAM) interface. By declaring it with thefun modifier, Kotlin enables SAM conversion, allowing you to instantiate the interface using lambda expressions.
Tired of Poor Kotlin Skills? Fix That With Deep Grasping!Learn More





