How to Pass a Kotlin Interview: Top Questions from A to Z

Online Python Trainer for Beginners

Learn Python easily without overwhelming theory. Solve practical tasks with automatic checking, get hints in Russian, and write code directly in your browser — no installation required.

Start Course

How to Pass a Kotlin Interview: Top Questions from A to Z



A Kotlin interview is not just a syntax check. Employers want to see that you understand the language's philosophy: null safety, functional style, idioms, and compilation specifics. In this article, we have broken down the most common questions — from basic to advanced. Prepare for your interview 100%.



1. Basic Questions: Syntax and Null Safety



The interview usually starts with the basics. Here's what you absolutely need to know.



What data types are there in Kotlin and how do they differ from Java?

Kotlin is a statically typed language. All types are objects, there are no primitives (but the compiler can optimize). Main types: Int, Double, Boolean, String, Array. Unlike Java, Kotlin does not use new to create objects, and nullable types are explicitly marked with a ? sign.



What is null safety and how does Kotlin implement it?

Null safety is built-in protection against NullPointerException. Types are divided into nullable (String?) and non-null (String). For safe access, use operators:

val name: String? = nullprintln(name?.length)       // safe call -> nullprintln(name?.length ?: 0)  // Elvis operator -> 0println(name!!.length)      // force -> NPE if null


How does val differ from var?

  • val — immutable reference (read-only). Analogous to final in Java.
  • var — mutable reference.

Important: val does not guarantee the immutability of the object itself, only the reference.



2. Advanced Constructs: Classes, Functions, and Sealed



Here they test your ability to write concise and safe code.



What is a data class and what methods does it generate?

data class is a class designed for holding data. The compiler automatically generates: equals(), hashCode(), toString(), copy(), and componentN().

data class User(val id: Int, val name: String)val user = User(1, "Alice")val copy = user.copy(name = "Bob")println(user) // User(id=1, name=Alice)


What is a sealed class and when should you use it?

sealed class is a restricted class hierarchy. All subclasses must be declared in the same file. It is ideal for representing states (e.g., a loading result).

sealed class Result {    data class Success(val data: String) : Result()    data class Error(val message: String) : Result()    object Loading : Result()}

fun handle(result: Result) = when (result) { is Result.Success -> println(result.data) is Result.Error -> println(result.message) Result.Loading -> println("Loading...")}

Advantage: when must be exhaustive — the compiler will check all variants.



What are extension functions and how do they work?

Extension functions allow you to add a new method to an existing class without inheritance. In reality, they are static functions that take an instance of the class as the first argument.

fun String.isEmail(): Boolean = this.contains("@")println("test@mail.ru".isEmail()) // true


3. Functional Programming: Lambdas, Collections, Scope Functions



Kotlin actively uses a functional approach. Be prepared for questions about working with collections and scope functions.



What scope functions do you know? How do they differ?

Main ones: let, run, with, apply, also. The main difference is the context (this or it) and the return value.

Blogs

Book Recommendations

FunctionContext