Android ● ● ○ Kotlin 2.0

Kodebits Day 61: Object Expression

Jul 20 2026
Practice objects with a short kotlin challenge.

What is the output?

interface Greeter {
  fun greet(): String
}
fun main() {
  val g = object : Greeter {
    override fun greet() = "Hi"
  }
  println(g.greet())
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

Hi

Explanation:

Object expressions create anonymous instances that implement interfaces or extend classes.

[/spoiler]


Further Reading