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

Abstract Classes in Kotlin

Abstract classes provide a partial implementation with both abstract and concrete members that subclasses complete.

Advanced OOPIntermediate8 min readJul 8, 2026
Analogies

Introduction

An abstract class is a class that cannot be instantiated directly; it serves as a blueprint for other classes. Abstract classes can contain both abstract members, which have no implementation and must be overridden, and concrete members, which already provide behavior. This makes them well suited for sharing common state and logic across a family of related subclasses while still forcing each subclass to implement the behavior specific to it. The abstract keyword marks both the class and any members that lack an implementation. Subclasses must override every abstract member using the override keyword, or they must also be declared abstract themselves. Unlike interfaces, abstract classes can hold constructor parameters and mutable state, and a class can extend only one abstract class (Kotlin has single inheritance for classes), while it can implement multiple interfaces.

🏏

Cricket analogy: An abstract class is like the BCCI's fitness protocol template: it mandates every player run the same yo-yo test (abstract member) but lets each franchise decide net-practice drills (concrete member) on its own.

Syntax

kotlin
abstract class Shape {
    abstract fun area(): Double

    fun describe(): String = "Area is ${area()}"
}

Example

kotlin
class Circle(val radius: Double) : Shape() {
    override fun area(): Double = Math.PI * radius * radius
}

class Rectangle(val width: Double, val height: Double) : Shape() {
    override fun area(): Double = width * height
}

fun main() {
    val shapes = listOf(Circle(2.0), Rectangle(3.0, 4.0))
    for (shape in shapes) {
        println(shape.describe())
    }
}

Output

kotlin
Area is 12.566370614359172
Area is 12.0

Key Takeaways

  • Abstract classes cannot be instantiated directly.
  • They can mix abstract members (no body) and concrete members (with body).
  • Subclasses must override all abstract members unless they too are abstract.
  • Abstract classes can hold constructor parameters and state, unlike interfaces.
  • A class can extend only one abstract class but implement many interfaces.

Practice what you learned

Was this page helpful?

Topics covered

#Kotlin#KotlinProgrammingStudyNotes#Programming#AbstractClassesInKotlin#Abstract#Classes#Syntax#Example#OOP#StudyNotes#SkillVeris