100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Kotlin

Interfaces in Kotlin

Explore how Kotlin interfaces define abstract methods, default implementations, and properties that classes can implement.

Classes & ObjectsIntermediate8 min readJul 8, 2026
Analogies

Introduction

An interface in Kotlin defines a contract of functions and properties that implementing classes must fulfill. Unlike abstract classes, interfaces cannot store state in backing fields, but they can provide default method implementations, making them a flexible tool for sharing behavior across otherwise unrelated classes.

🏏

Cricket analogy: Like an ICC playing-conditions rulebook that mandates what every match must include (overs, DRS reviews) without dictating a specific team's lineup, a Kotlin interface defines a contract of functions and properties without storing state itself.

Syntax

kotlin
interface Drawable {
    val color: String

    fun draw()

    fun describe() {
        println("A $color shape")
    }
}

Explanation

Drawable declares an abstract property color (no backing field, so implementing classes must provide it), an abstract function draw() with no body, and a function describe() that has a default implementation. A class implements an interface using the colon : syntax and must override any abstract members with the override keyword; it may optionally override members that already have default implementations. Because interfaces have no constructors and cannot hold state directly, a class can implement multiple interfaces simultaneously without the diamond-inheritance issues that plague multiple class inheritance.

🏏

Cricket analogy: Like a Drawable-style playing-conditions contract requiring every team to declare its color (jersey scheme, no default kit provided) and follow a mandatory draw()-like coin-toss procedure, while describe() comes with a standard default script; a team can follow multiple such rulebooks without conflicting mandates like diamond inheritance would cause.

Example

kotlin
interface Drawable {
    val color: String
    fun draw()
    fun describe() {
        println("A $color shape")
    }
}

class Circle(override val color: String) : Drawable {
    override fun draw() {
        println("Drawing a $color circle")
    }
}

fun main() {
    val circle = Circle("red")
    circle.draw()
    circle.describe()
}

Output

text
Drawing a red circle
A red shape

Key Takeaways

  • Interfaces declare abstract methods and can also provide default implementations.
  • Interface properties cannot have backing fields; implementers must provide the value.
  • A class implements an interface with the colon syntax and overrides abstract members.
  • A class can implement multiple interfaces, avoiding single-inheritance limitations.
  • Default methods reduce duplicated code across multiple implementing classes.

Practice what you learned

Was this page helpful?

Topics covered

#Kotlin#KotlinProgrammingStudyNotes#Programming#InterfacesInKotlin#Interfaces#Syntax#Explanation#Example#StudyNotes#SkillVeris