Top 20 Kotlin interview questions and answers 2025-2026
October 16, 2025
1️⃣ What are the key features of Kotlin?
Answer:
- Concise and expressive syntax
- Null safety (
?and!!) - Interoperable with Java
- Extension functions
- Coroutines for asynchronous programming
- Data classes and Sealed classes
2️⃣ Difference between val and var.
Answer:
val→ immutable (likefinalin Java)var→ mutable, value can change
3️⃣ What are Data Classes in Kotlin?
Answer:
- Classes used to hold data
- Auto-generates:
toString(),equals(),hashCode(),copy(),componentN()
data class User(val name: String, val age: Int)
4️⃣ Explain Null Safety in Kotlin.
Answer:
- Kotlin prevents NullPointerException using
?operator - Safe call:
user?.name - Elvis operator:
val length = user?.name?.length ?: 0 - Not-null assertion:
user!!.name(throws exception if null)
5️⃣ Difference between == and ===.
Answer:
==→ structural equality (checks values)===→ referential equality (checks if objects point to same memory)
6️⃣ What are Extension Functions?
Answer:
- Add functions to existing classes without inheritance
fun String.addExclamation() = this + "!"
val text = "Hello".addExclamation() // "Hello!"
7️⃣ Explain Sealed Classes.
Answer:
- Used for restricted class hierarchies
- All subclasses known at compile time
- Useful in when expressions
sealed class Result
data class Success(val data: String) : Result()
data class Error(val error: String) : Result()
8️⃣ Difference between open, abstract, and final classes.
Answer:
final→ default, cannot inheritopen→ can be inheritedabstract→ cannot be instantiated, may have abstract members
9️⃣ What are Coroutines in Kotlin?
Answer:
- Lightweight threads for asynchronous programming
- Use
suspendfunctions,launch,async, andwithContext - Reduces callback hell and improves performance
10️⃣ Difference between launch and async.
Answer:
launch→ returnsJob, does not return resultasync→ returnsDeferred<T>, can return result usingawait()
11️⃣ Explain lateinit vs lazy.
Answer:
lateinit→ for var, initialized later, avoids nulllazy→ for val, initialized on first access
lateinit var name: String
val age: Int by lazy { 25 }
12️⃣ Difference between object and companion object.
Answer:
object→ singleton instancecompanion object→ static members in class
class MyClass {
companion object { val id = 1 }
}
13️⃣ Explain Higher-Order Functions.
Answer:
- Functions that take functions as parameters or return functions
fun operate(x: Int, y: Int, op: (Int, Int) -> Int) = op(x, y)
val sum = operate(2, 3) { a, b -> a + b } // 5
14️⃣ Difference between map, flatMap, filter in Kotlin.
Answer:
map→ transforms each elementflatMap→ maps and flattens nested collectionsfilter→ selects elements based on condition
15️⃣ What are Inline Functions?
Answer:
- Functions marked
inlineare inlined at call site - Reduces runtime overhead, useful for higher-order functions
16️⃣ Explain typealias in Kotlin.
Answer:
- Provides alternative name for type
- Useful for long generic types
typealias StringMap = Map<String, String>
val data: StringMap = mapOf("a" to "1")
17️⃣ What are Kotlin Collections?
Answer:
List→ ordered, can be mutable/immutableSet→ unique elementsMap→ key-value pairs- Functions:
map,filter,forEach,reduce,fold
18️⃣ Difference between Any, Unit, and Nothing.
Answer:
Any→ supertype of all non-null typesUnit→ likevoidin JavaNothing→ type with no value, useful for exceptions
19️⃣ Explain Kotlin Delegation.
Answer:
- Kotlin supports delegating responsibilities to another object
bykeyword used
interface Base { fun print() }
class BaseImpl(val x: Int) : Base { override fun print() = println(x) }
class Derived(b: Base) : Base by b
20️⃣ Difference between const val and val.
Answer:
val→ read-only runtime constantconst val→ compile-time constant, can only hold primitive types or String