Free Kotlin Interview Questions

Kotlin language essentials and the tricky corners interviewers actually probe.

Browse all 50 questions. Sign in with a free account to reveal the detailed answers.

  1. Does declaring a variable with val make the object it references immutable?

    Sign in to view the detailed answer.

  2. Is a List returned by listOf actually immutable, and can it ever change under your feet?

    Sign in to view the detailed answer.

  3. What is the difference between == and === in Kotlin?

    Sign in to view the detailed answer.

  4. What is a platform type, and why can it cause a surprise NullPointerException even in null-safe Kotlin?

    Sign in to view the detailed answer.

  5. When you call copy() on a data class holding a mutable list, is the copy independent of the original?

    Sign in to view the detailed answer.

  6. What is the practical difference between lateinit var and by lazy for deferred initialization?

    Sign in to view the detailed answer.

  7. Do the scope functions let, run, also, apply, and with differ only in style, or is there a real semantic distinction?

    Sign in to view the detailed answer.

  8. Why can an extension function not override a member function, and what determines which one is called?

    Sign in to view the detailed answer.

  9. What does the inline keyword actually do to a higher-order function, and what problem does it solve?

    Sign in to view the detailed answer.

  10. What do noinline and crossinline do, and when are they each required?

    Sign in to view the detailed answer.

  11. What does a reified type parameter enable that a normal generic type parameter cannot, and what is the requirement?

    Sign in to view the detailed answer.

  12. Why should you not add or remove elements from a MutableList while iterating it, and how does Kotlin behave?

    Sign in to view the detailed answer.

  13. What is the difference between const val and a regular val, and where can const be used?

    Sign in to view the detailed answer.

  14. When are you forced to override both equals and hashCode together, and what breaks if you do not?

    Sign in to view the detailed answer.

  15. Why might comparing two Double values with == give a surprising result, especially with NaN?

    Sign in to view the detailed answer.

  16. What is the difference between a sealed class and an enum, and when do you choose each?

    Sign in to view the detailed answer.

  17. What is the difference between a companion object and a plain object declaration?

    Sign in to view the detailed answer.

  18. Why is a Kotlin companion object member not automatically a Java static, and how do you fix interop?

    Sign in to view the detailed answer.

  19. What is the difference between a Sequence and a List when chaining map and filter, and why does it matter for performance?

    Sign in to view the detailed answer.

  20. Why can the compiler refuse to smart-cast a nullable var even right after a null check?

    Sign in to view the detailed answer.

  21. What does declaration-site variance with out and in mean, and how does it differ from Java wildcards?

    Sign in to view the detailed answer.

  22. What is a star projection, and how is List of star different from List of Any?

    Sign in to view the detailed answer.

  23. What is type erasure in Kotlin generics, and what specifically can you not do because of it?

    Sign in to view the detailed answer.

  24. What is a value class (formerly inline class), and when does it actually avoid allocation?

    Sign in to view the detailed answer.

  25. Can an extension function be called on a null receiver, and how does that work?

    Sign in to view the detailed answer.

  26. What is the difference between an inner class and a nested class in Kotlin?

    Sign in to view the detailed answer.

  27. How does a suspend function work under the hood, and why can you only call it from a coroutine?

    Sign in to view the detailed answer.

  28. What makes a when expression exhaustive, and when are you not required to write an else branch?

    Sign in to view the detailed answer.

  29. What is the Nothing type in Kotlin and where does it show up usefully?

    Sign in to view the detailed answer.

  30. What does a Kotlin contract do, and why is require or isNullOrEmpty able to help smart-casting?

    Sign in to view the detailed answer.

  31. How does destructuring work in Kotlin, and why is it positional rather than by name?

    Sign in to view the detailed answer.

  32. What is a tailrec function, and what silently prevents the optimization?

    Sign in to view the detailed answer.

  33. How do property delegates like by lazy and Delegates.observable actually work?

    Sign in to view the detailed answer.

  34. What is a typealias, and what does it not give you compared to a value class?

    Sign in to view the detailed answer.

  35. How does operator overloading resolve in Kotlin, and what are the constraints on which functions you can overload?

    Sign in to view the detailed answer.

  36. What is the difference between JvmField, JvmStatic, and JvmOverloads, and when do you need each?

    Sign in to view the detailed answer.

  37. What does a labeled return like return at a label do, and why is it needed inside a lambda?

    Sign in to view the detailed answer.

  38. Why does adding a non-constructor property to a data class exclude it from equals, hashCode, and copy?

    Sign in to view the detailed answer.

  39. How do default arguments interact with copy on a data class, and what is the pitfall?

    Sign in to view the detailed answer.

  40. Why can you not smart-cast a property declared with a custom getter, and what is the safe alternative?

    Sign in to view the detailed answer.

  41. What is the difference between associate, associateBy, and associateWith, and where do you lose data?

    Sign in to view the detailed answer.

  42. What is the difference between flatMap and map plus flatten, and when does a wrong transform surprise you?

    Sign in to view the detailed answer.

  43. How does Kotlin's elvis operator combined with return or throw enable early exit, and why does it type-check?

    Sign in to view the detailed answer.

  44. What is the difference between a reified is T check and a plain Class comparison for generics, and what does filterIsInstance rely on?

    Sign in to view the detailed answer.

  45. Why does modifying a captured var inside a Kotlin lambda work, unlike Java's effectively-final rule?

    Sign in to view the detailed answer.

  46. What is the difference between an anonymous object expression and a lambda when implementing an interface, and when must you use each?

    Sign in to view the detailed answer.

  47. How does the by keyword implement interface delegation, and what surprising override behavior can it produce?

    Sign in to view the detailed answer.

  48. What does the in and out variance actually forbid you from doing, illustrated with a covariant class trying to consume its type?

    Sign in to view the detailed answer.

  49. Why can two functions with the same name but different generic parameters clash on the JVM, and how do JvmName and mangling help?

    Sign in to view the detailed answer.

  50. How do coroutine structured concurrency, the Nothing type, and suspend combine to make cancellation cooperative, and what breaks it?

    Sign in to view the detailed answer.

Practice all Kotlin questions interactively

Search and filter questions in the free Preparation Path, then sign in to reveal answers and save your progress.

Open free Preparation Path

More Android interview topics