Kotlin Interview Questions & Answers (2025 Edition)
1. What is Kotlin?
Kotlin is a modern, statically typed programming language that runs on the JVM. It is officially supported by Google for Android development.
2. Difference between val
and var
-
val
: Immutable variable (likefinal
in Java) -
var
: Mutable variable
3. What is a data class?
Used to hold data. Kotlin automatically provides toString()
, hashCode()
, and copy()
.
4. Difference between ==
and ===
-
==
: Structural equality (compares content) -
===
: Referential equality (compares references)
5. What are nullable types?
Kotlin prevents null pointer exceptions with nullable types.
6. What is a Kotlin function?
7. What is a Lambda in Kotlin?
Anonymous function used to simplify code.
8. Difference between fun
and Unit
-
fun
: Declares a function -
Unit
: Kotlin’s equivalent ofvoid
in Java
9. What is the difference between List
and MutableList
-
List
: Immutable -
MutableList
: Can be modified
10. What is smart casting?
Kotlin automatically casts types after checking with is
.
Medium Questions (11–20)
11. Explain when
expression
Kotlin’s enhanced switch
.
12. Difference between open
, final
, and abstract
-
open
: Can be inherited -
final
: Default, cannot be inherited -
abstract
: Must be implemented in subclasses
13. What is a companion object?
Allows static-like behavior in Kotlin.
14. Explain object
keyword
Declares a singleton object.
15. Difference between by lazy
and lateinit
-
by lazy
: Lazy initialization -
lateinit
: Non-null property initialized later
16. Explain extension functions
Add functions to existing classes without inheritance.
17. Difference between Array
and List
-
Array
: Fixed size, mutable -
List
: Immutable by default
18. Explain higher-order functions
Functions that take or return functions.
19. Difference between const val
and val
-
const val
: Compile-time constant -
val
: Runtime constant
20. What are sealed classes?
Restricted class hierarchy, useful in state management.
Difficult Questions (21–30)
21. Explain coroutines in Kotlin
Lightweight threads for asynchronous programming.
22. Difference between runBlocking
and launch
-
runBlocking
: Blocks current thread -
launch
: Non-blocking coroutine
23. Explain Kotlin Flow
Asynchronous stream of data, similar to RxJava.
24. What are inline functions?
Reduce overhead of higher-order functions by inlining at compile-time.
25. Difference between interface
and abstract class
-
Interface: Multiple inheritance
-
Abstract class: Single inheritance, can have state
26. Explain delegation
Kotlin supports class delegation to reuse functionality.
27. Explain typealiases
Aliases for long type definitions.
28. Explain reified generics
Allows type information at runtime for inline functions.
29. How to handle null safety
-
?.
safe call -
?:
Elvis operator -
!!
force unwrap
30. Difference between suspend
and async
-
suspend
: Marks function as coroutine -
async
: Launches coroutine and returnsDeferred
✍️ By Not available | 2025-10-21T09:01:33.334Z