Kotlin MCQ
Test your Kotlin knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
How This Practice Test Works
Every question below expands right on this page — click a question to reveal its four options, pick the one you think is correct, and you'll get instant feedback along with the correct answer and a short explanation of the reasoning. Questions are grouped by difficulty, so start with the 41 beginner questions to confirm your fundamentals, work through the 40 intermediate ones, and finish with the 19 advanced questions that mirror what exams and technical screenings actually ask. There's no sign-up, no timer, and no limit — retake the test as often as you like.
Curated by Tech Baithak Editorial Team · Last updated: June 2026
1
Which company developed the Kotlin programming language?
Correct Answer
JetBrains
Explanation
Kotlin was developed by JetBrains and first released in 2011. It became an official language for Android development in 2017.
2
How do you declare an immutable variable in Kotlin?
Correct Answer
val x = 5
Explanation
val declares a read-only (immutable) reference. var declares a mutable variable that can be reassigned.
3
What is the Kotlin keyword for declaring a nullable type?
Correct Answer
?
Explanation
Appending ? to a type (e.g., String?) marks it as nullable, allowing null values. Without ?, Kotlin types are non-nullable by default.
4
What does the Elvis operator ?: do?
Correct Answer
Returns the left-hand value if non-null, otherwise the right-hand value
Explanation
The Elvis operator (val result = a ?: b) returns a if it's not null, otherwise returns b.
5
What is a data class in Kotlin?
Correct Answer
A class that auto-generates equals, hashCode, toString, copy, and componentN functions based on primary constructor properties
Explanation
Data classes (data class Person(val name: String)) are designed to hold data and auto-generate boilerplate methods.
6
How do you define a function in Kotlin?
Correct Answer
fun greet(): Unit
Explanation
Kotlin uses the fun keyword to declare functions.
7
What is a Kotlin object declaration?
Correct Answer
A thread-safe singleton
Explanation
object MyObject { } declares a singleton in Kotlin — only one instance exists, created lazily on first access.
8
What does the safe call operator ?. do?
Correct Answer
Calls a method only if the receiver is not null; otherwise returns null
Explanation
str?.length returns null if str is null rather than throwing a NullPointerException.
9
What is a companion object in Kotlin?
Correct Answer
An object declared inside a class that provides class-level (static-like) members
Explanation
companion object acts like static members in Java, accessible via the class name, e.g., MyClass.create().
10
What is a sealed class in Kotlin?
Correct Answer
A class that restricts its subclasses to be defined in the same file
Explanation
Sealed classes restrict the class hierarchy to a known set of subclasses, enabling exhaustive when expressions.
11
How do you declare a primary constructor in Kotlin?
Correct Answer
class Person(val name: String)
Explanation
Kotlin allows declaring the primary constructor directly in the class header with optional val/var to create properties.
12
What is string interpolation in Kotlin?
Correct Answer
Embedding expressions inside a string using $ or ${}
Explanation
"Hello, $name!" or "${user.fullName}" embeds variable values or expressions directly in string literals.
13
What is the difference between == and === in Kotlin?
Correct Answer
== checks structural equality (calls equals()); === checks referential equality
Explanation
In Kotlin, == is the safe structural equality (null-safe equals()), while === checks if two references point to the same object.
14
Which keyword is used for type casting in Kotlin?
Correct Answer
variable as Type
Explanation
Kotlin uses as for unsafe casting and as? for safe casting (returns null instead of throwing on failure).
15
What is a lambda expression in Kotlin?
Correct Answer
An anonymous function that can be stored in a variable or passed as an argument, written as { params -> body }
Explanation
Kotlin lambdas are written as { x: Int -> x * 2 }. If there's a single parameter, you can use the implicit it.
16
What does the when expression replace in Kotlin?
Correct Answer
The switch statement from Java
Explanation
when replaces Java's switch and is more powerful — it can match ranges, types, and expressions, and can be used as a statement or expression.
17
What is the Unit type in Kotlin?
Correct Answer
An alias for void in Kotlin
Explanation
Unit corresponds to Java's void. Functions that return nothing return Unit, which can be omitted from the function signature.
18
How do you declare an interface in Kotlin?
Correct Answer
interface MyInterface
Explanation
Kotlin uses the interface keyword. Unlike Java, Kotlin interfaces can have property declarations and default implementations.
19
What is an extension function in Kotlin?
Correct Answer
A function that adds new functionality to an existing class without modifying its source code
Explanation
fun String.shout() = uppercase() + "!" adds a shout() method to String without subclassing or modifying String.
20
What does the !! (not-null assertion) operator do?
Correct Answer
Converts a nullable type to non-null, throwing KotlinNullPointerException if null
Explanation
value!! asserts the value is non-null. If it is null, a KotlinNullPointerException is thrown. Use sparingly.
21
What is the Kotlin equivalent of Java's static methods?
Correct Answer
Both B and C are valid
Explanation
Kotlin doesn't have static. You can use companion object functions (class-level) or top-level functions (package-level) as alternatives.
22
What is the difference between List and MutableList in Kotlin?
Correct Answer
List is read-only; MutableList supports add, remove, and set operations
Explanation
Kotlin distinguishes read-only (List) from mutable (MutableList) collection interfaces, promoting immutability by default.
23
What does the init block do in a Kotlin class?
Correct Answer
Contains code that runs as part of the primary constructor
Explanation
init blocks run in declaration order as part of primary constructor execution, useful for validation or complex initialization.
24
How do you declare default parameter values in Kotlin?
Correct Answer
fun greet(name: String = "World")
Explanation
Kotlin supports default parameter values directly in the function signature, reducing the need for overloads.
25
What is a Kotlin enum class?
Correct Answer
A class with a fixed set of named constant instances
Explanation
enum class Direction { NORTH, SOUTH, EAST, WEST } creates named constants. Enum classes can have properties and methods.
26
What is the purpose of the open keyword in Kotlin?
Correct Answer
To mark a class or method as inheritable/overridable (since all are final by default)
Explanation
In Kotlin, classes and members are final by default. The open modifier allows them to be subclassed or overridden.
27
What does the let scope function do?
Correct Answer
Executes a lambda on a non-null object and returns the lambda's result; object is referred to as it
Explanation
let is often used for null-safe chaining: nullableObj?.let { doSomethingWith(it) }. It returns the lambda result.
28
What does the apply scope function return?
Correct Answer
The receiver object itself
Explanation
apply executes a lambda where this refers to the receiver and returns the receiver itself, ideal for object initialization.
29
What is a higher-order function?
Correct Answer
A function that takes other functions as parameters or returns a function
Explanation
Higher-order functions treat functions as first-class citizens. Examples include map, filter, and reduce from the standard library.
30
Which collection function transforms each element to a new value?
Correct Answer
map
Explanation
map applies a transformation lambda to each element and returns a new list of results.
31
How does Kotlin handle null safety compared to Java?
Correct Answer
Kotlin types are non-nullable by default; null must be explicitly opted into with ?
Explanation
Kotlin's type system distinguishes nullable (String?) from non-nullable (String) at compile time, catching most NullPointerExceptions before runtime.
32
What is a property in Kotlin?
Correct Answer
A class field with optional custom getter and setter
Explanation
Kotlin properties replace Java fields + getter/setter patterns. You can customize access with get() and set(value) blocks.
33
What does @JvmStatic do on a companion object function?
Correct Answer
Generates a true static JVM method, allowing Java callers to invoke it without a companion reference
Explanation
@JvmStatic on a companion object function generates a static method in the class bytecode for seamless Java interoperability.
34
What is the Nothing type in Kotlin?
Correct Answer
A type that has no instances; used for functions that never return (e.g., throw or infinite loops)
Explanation
Functions returning Nothing always throw an exception or loop forever. It is a subtype of all types, useful for throw expressions in when branches.
35
How does Kotlin smart cast work?
Correct Answer
After an is type check, the compiler automatically treats the variable as the checked type within the conditional scope
Explanation
After if (x is String) { ... }, x is automatically treated as String inside the block — no explicit cast needed.
36
What is the Kotlin Range operator ..?
Correct Answer
Creates an inclusive range between two values
Explanation
1..10 creates an IntRange from 1 to 10 inclusive, usable in for loops and in checks.
37
What is the difference between var and val?
Correct Answer
var is mutable (can be reassigned); val is read-only
Explanation
var allows reassignment; val doesn't. Note that val only prevents reference reassignment — a mutable object held by val can still be mutated.
38
How do you iterate over a list in Kotlin?
Correct Answer
for (item in list)
Explanation
Kotlin uses for (item in collection) for iteration, similar to Java's enhanced for loop.
39
What does the also scope function do?
Correct Answer
Performs side-effect actions on an object and returns the object itself; parameter is it
Explanation
also is like apply but uses it instead of this, and returns the receiver. Useful for side-effects like logging.
40
What is the use of the @Suppress annotation?
Correct Answer
Suppresses compiler warnings for specific rules
Explanation
@Suppress("UNCHECKED_CAST") tells the compiler to silence a specific warning for the annotated element.
41
What is a Pair in Kotlin?
Correct Answer
A data class holding two values, accessible via .first and .second
Explanation
Pair<A, B> is a data class with first and second properties. You can create one with Pair(a, b) or the infix to function: a to b.
1
What is a Kotlin coroutine?
Correct Answer
A lightweight concurrency primitive that can be suspended and resumed without blocking a thread
Explanation
Coroutines are Kotlin's mechanism for asynchronous and concurrent programming. They are cheap, can suspend at suspension points, and resume later without blocking.
2
What is the difference between suspend fun and a regular fun?
Correct Answer
A suspend function can be paused and resumed later; it can only be called from a coroutine or another suspend function
Explanation
The suspend modifier allows a function to use suspension points (like delay or await). The compiler transforms it into a state machine.
3
What is the difference between launch and async coroutine builders?
Correct Answer
launch fires-and-forgets returning a Job; async returns a Deferred<T> that can be awaited
Explanation
launch is for fire-and-forget coroutines. async is for coroutines that produce a result accessed via Deferred.await().
4
What does the inline keyword do for a higher-order function?
Correct Answer
Inlines the function body into the call site, avoiding lambda object allocation
Explanation
Inline functions copy their body (and the lambda bodies) to each call site at compile time, eliminating the overhead of lambda object creation and virtual dispatch.
5
What is the purpose of reified type parameters?
Correct Answer
To retain the generic type at runtime inside inline functions, enabling is and as checks on type parameters
Explanation
Normally, generics are erased at runtime. reified (only in inline functions) preserves the type, allowing inline fun <reified T> isOf(value: Any) = value is T.
6
What is delegation in Kotlin using the by keyword?
Correct Answer
Forwarding interface implementation or property access to another object automatically
Explanation
class Derived(base: Base) : Base by base delegates all Base method calls to base. Property delegation (val x by Delegate()) customizes get/set.
7
What is the lazy property delegate?
Correct Answer
A property whose initialization is deferred until first access
Explanation
val heavy by lazy { expensiveComputation() } only runs expensiveComputation() on the first access, caching the result for subsequent reads.
8
What does withContext(Dispatchers.IO) do in a coroutine?
Correct Answer
Switches the coroutine's dispatcher for a block without creating a new coroutine
Explanation
withContext suspends the current coroutine, switches to the specified dispatcher, executes the block, then resumes on the original dispatcher.
9
What is a Flow in Kotlin coroutines?
Correct Answer
A cold asynchronous stream of values that emits multiple values over time
Explanation
Flow<T> is a cold stream — it starts emitting only when collected. It supports operators like map, filter, and flatMap for reactive-style programming.
10
What is the difference between StateFlow and SharedFlow?
Correct Answer
StateFlow holds a current value and replays it to new collectors; SharedFlow is configurable and doesn't require a current value
Explanation
StateFlow is like LiveData — it always has a value and emits updates. SharedFlow is more flexible with configurable replay, buffer, and overflow strategies.
11
What does structured concurrency mean in Kotlin?
Correct Answer
Coroutines live within a defined scope; the scope doesn't complete until all its coroutines complete, and cancellation propagates
Explanation
Structured concurrency (via CoroutineScope) ensures coroutines don't leak: if a scope is cancelled, all its children are cancelled too.
12
What is the purpose of the operator keyword?
Correct Answer
To allow operator overloading by linking a function to a specific operator symbol
Explanation
operator fun plus(other: MyType) enables using + with your custom class.
13
What is a destructuring declaration?
Correct Answer
Unpacking a component into multiple variables: val (a, b) = pair
Explanation
val (name, age) = person unpacks the data class via component1(), component2() functions. Works for data classes, Pairs, and Map entries.
14
What does crossinline do in an inline function?
Correct Answer
Prohibits non-local returns from the lambda while still allowing inlining
Explanation
crossinline is needed when a lambda is invoked in a different execution context (e.g., inside another lambda) where non-local returns would be unsafe.
15
What is the difference between object and class in Kotlin?
Correct Answer
object is a singleton; class can be instantiated multiple times
Explanation
An object declaration creates a singleton — one instance is created lazily and shared globally. A class is a blueprint for creating multiple instances.
16
How does Kotlin's type inference work?
Correct Answer
The compiler deduces the type from the assigned value or return type, so explicit type annotations are often optional
Explanation
val x = 42 infers Int. val list = listOf("a") infers List<String>. The compiler analyzes the expression to determine the type.
17
What is a type alias in Kotlin?
Correct Answer
A new name for an existing type without creating a new type
Explanation
typealias StringList = List<String> creates an alias. Useful for shortening complex generic types but does not provide type safety.
18
What is a value class (inline class) in Kotlin?
Correct Answer
A class that wraps a primitive for type safety without allocation overhead at runtime
Explanation
@JvmInline value class Email(val value: String) gives type safety (Email vs String) but is represented as String in JVM bytecode, avoiding boxing.
19
What does the contract block in Kotlin allow?
Correct Answer
Providing the compiler hints about runtime behavior to improve smart casts and null analysis
Explanation
Contracts (kotlin.contracts) let functions declare guarantees (e.g., "if this returns true, parameter x is not null") so the compiler can perform better smart casts.
20
What is vararg in Kotlin?
Correct Answer
A function parameter that accepts a variable number of arguments of the same type
Explanation
fun sum(vararg numbers: Int) allows calling sum(1, 2, 3). Inside the function, numbers is an IntArray.
21
What is the spread operator * used for with vararg?
Correct Answer
Passing the contents of an array as individual vararg arguments
Explanation
If fun f(vararg xs: Int) and vals arr = intArrayOf(1, 2), call f(*arr) to unpack the array as individual arguments.
22
How do you handle exceptions in Kotlin?
Correct Answer
With try-catch-finally; all exceptions are unchecked in Kotlin
Explanation
Kotlin has no checked exceptions. try-catch is used but not enforced by the compiler. runCatching is a functional alternative returning Result.
23
What does the run scope function return?
Correct Answer
The result of the lambda
Explanation
run executes a lambda where this refers to the receiver and returns the lambda's result. It is useful for object initialization combined with computation.
24
What is the purpose of SupervisorJob in coroutines?
Correct Answer
To prevent a child coroutine failure from cancelling sibling coroutines
Explanation
With a regular Job, a failing child cancels the parent and all siblings. SupervisorJob isolates failures so only the failed child is cancelled.
25
What is channel in Kotlin coroutines?
Correct Answer
A coroutine-safe queue for communicating between coroutines via send and receive
Explanation
Channel<T> is like a BlockingQueue but non-blocking. Coroutines use send() to produce and receive() to consume, supporting producer-consumer patterns.
26
How does Kotlin support multiple interface implementation?
Correct Answer
A class can implement multiple interfaces by listing them comma-separated after the colon
Explanation
class MyClass : InterfaceA, InterfaceB, ParentClass() implements multiple interfaces and optionally extends one class.
27
What is the difference between Dispatchers.Main and Dispatchers.IO?
Correct Answer
Dispatchers.Main runs coroutines on the UI thread; Dispatchers.IO uses a thread pool optimized for blocking I/O
Explanation
Dispatchers.Main is the UI dispatcher. Dispatchers.IO has a large thread pool (default 64) designed for blocking I/O like network or disk operations.
28
What is kotlinx.coroutines.flow.catch operator used for?
Correct Answer
Handling exceptions thrown upstream in a Flow chain, allowing recovery or re-emission
Explanation
flow.catch { e -> emit(defaultValue) } handles exceptions from upstream operators. It does not catch exceptions in downstream operators.
29
What is the combine Flow operator?
Correct Answer
Combines the latest values from multiple flows whenever any flow emits a new value
Explanation
combine(flow1, flow2) { a, b -> a + b } re-evaluates the transform whenever either flow1 or flow2 emits. Useful for reactive UI state combination.
30
What is the difference between flatMapConcat and flatMapMerge?
Correct Answer
flatMapConcat processes inner flows sequentially; flatMapMerge processes them concurrently with configurable concurrency
Explanation
flatMapConcat waits for each inner flow to complete before starting the next. flatMapMerge starts all inner flows concurrently (default concurrency = 16).
31
What does the Kotlin by lazy(LazyThreadSafetyMode.NONE) do?
Correct Answer
Skips thread-safety guarantees for maximum performance in single-threaded contexts
Explanation
LazyThreadSafetyMode.NONE removes synchronization overhead. Use when you are certain the property will only be accessed from one thread.
32
What is Kotlin's type-safe builder pattern?
Correct Answer
A DSL approach using receiver lambdas (T.() -> Unit) to create structured, readable object configuration DSLs
Explanation
html { body { p { +"Hello" } } } uses type-safe builders. Each function accepts a receiver lambda, scoping available methods to the context object.
33
What is the with scope function?
Correct Answer
Calls a lambda on an object passed as the first argument, with the object accessible as this; returns the lambda result
Explanation
with(textView) { text = "Hello"; textSize = 16f } is useful when calling multiple methods on the same non-nullable object.
34
What is the difference between coroutineScope and supervisorScope?
Correct Answer
coroutineScope cancels all children when one fails; supervisorScope lets siblings continue when one child fails
Explanation
coroutineScope propagates child failures. supervisorScope (like SupervisorJob) isolates failures — useful when parallel tasks are independent.
35
What is the purpose of Kotlin's @Volatile annotation?
Correct Answer
Maps to Java's volatile keyword, ensuring visibility of changes across threads without caching in CPU registers
Explanation
@Volatile var flag = false ensures reads/writes go directly to main memory, making state changes visible across threads immediately.
36
What is Kotlin's @Synchronized annotation?
Correct Answer
Maps to Java's synchronized method modifier, locking on the object instance for the duration of the function
Explanation
@Synchronized fun update() compiles to a synchronized method on the JVM, acquiring the monitor lock on the object before entering.
37
What is the difference between Kotlin's List and Array?
Correct Answer
Array is a Java array with a fixed size; List is a Kotlin collection interface with rich API and two implementations (read-only and mutable)
Explanation
Kotlin's Array maps directly to Java arrays. List/MutableList are Kotlin interfaces with richer API. Prefer List unless interop or performance requires Array.
38
What is Kotlin's buildString function?
Correct Answer
A concise way to build a string using a StringBuilder with an apply-like DSL: buildString { append("Hello"); append(name) }
Explanation
buildString { append("Hello, "); append(name); append("!") } is equivalent to StringBuilder().apply { ... }.toString() but cleaner.
39
What is the Kotlin Coroutines CoroutineExceptionHandler?
Correct Answer
A coroutine context element that handles uncaught exceptions from launch coroutines
Explanation
CoroutineExceptionHandler { _, exception -> log(exception) } is set as context: launch(handler) { }. It only handles exceptions from launch, not async (which stores them in Deferred).
40
What are Kotlin value classes used for instead of type aliases?
Correct Answer
Value classes create truly distinct types for type-safety while being erased to the underlying type at runtime
Explanation
@JvmInline value class Email(val value: String) creates a type distinct from String — passing a String where Email is expected is a compile error, unlike a type alias.
1
How does Kotlin implement coroutine suspension internally?
Correct Answer
The compiler transforms suspend functions into state machines using a Continuation callback parameter
Explanation
The Kotlin compiler desugars suspend functions into state machines with a Continuation<T> parameter. Each suspension point becomes a state; the continuation is resumed when the result is available.
2
What is the Continuation Passing Style (CPS) transformation?
Correct Answer
The compiler technique of adding a Continuation parameter to suspend functions to enable suspension and resumption
Explanation
CPS transformation adds an implicit Continuation<T> to every suspend function. The state machine calls continuation.resumeWith(result) when the async operation completes.
3
What is the difference between cold and hot Flows?
Correct Answer
Cold flows produce values on demand (new producer per collector); hot flows produce values regardless of collectors and share them
Explanation
Regular flow {} is cold — it starts fresh for each collector. StateFlow and SharedFlow are hot — they exist independently of collectors and share emissions.
4
What does noinline do in an inline function parameter?
Correct Answer
Marks a specific lambda parameter to not be inlined, allowing it to be stored or passed elsewhere
Explanation
In an inline function with multiple lambda parameters, noinline marks specific lambdas that should be compiled as objects (not inlined), needed when storing the lambda.
5
How does Kotlin enforce null-safety at the JVM bytecode level?
Correct Answer
Through @Nullable/@NotNull annotations and intrinsic null checks inserted by the compiler
Explanation
The Kotlin compiler emits intrinsic null-check bytecode (Intrinsics.checkNotNull) for non-null parameter receivers, plus @Nullable/@NonNull annotations for Java interop.
6
What is the purpose of Kotlin's arrow (->) in a function type?
Correct Answer
In type notation (A) -> B, it separates parameter types from the return type
Explanation
(Int, String) -> Boolean is a function type taking Int and String and returning Boolean. The -> separates parameter types from the return type.
7
What is Kotlin Multiplatform (KMP) and what does it share?
Correct Answer
A framework for sharing business logic (models, repositories, use-cases) across JVM, JS, and Native targets from a common source set
Explanation
KMP allows a commonMain source set to target Android (JVM), iOS (Kotlin/Native), Web (Kotlin/JS), and Desktop. Platform-specific implementations use expect/actual.
8
What are expect and actual declarations in KMP?
Correct Answer
expect declares an API in common code; actual provides a platform-specific implementation in each target
Explanation
expect class Platform() declares a type in commonMain. Each platform (androidMain, iosMain) provides actual class Platform() with its implementation.
9
How does Kotlin's coroutine Scope cancellation propagate?
Correct Answer
Cancelling a scope cancels all its children; each child throws CancellationException at its next suspension point
Explanation
Cancellation is cooperative. Cancelling a Job propagates to all descendants. Suspending functions (like delay) check for cancellation and throw CancellationException when cancelled.
10
What is the Mutex in Kotlin coroutines and how does it differ from synchronized?
Correct Answer
Mutex is a coroutine-aware mutual exclusion lock that suspends (not blocks) the waiting coroutine
Explanation
synchronized blocks the thread while waiting for the lock. Mutex.withLock { } suspends the coroutine at lock acquisition, freeing the thread for other coroutines.
11
What is Kotlin's tail-recursive optimization (tailrec)?
Correct Answer
The compiler replaces a tail-recursive function with a loop to prevent StackOverflowError
Explanation
tailrec fun factorial(n: Long, acc: Long = 1): Long is transformed by the compiler into a while loop, allowing deep recursion without stack overflow.
12
What is Kotlin's multiplatform expect/actual mechanism at the compiler level?
Correct Answer
The compiler matches each expect declaration in commonMain to its actual implementation in platform source sets during compilation
Explanation
The Kotlin compiler resolves expect/actual linkage at compile time. If a platform source set lacks an actual for an expected declaration, compilation fails.
13
What is IR (Intermediate Representation) in the Kotlin compiler?
Correct Answer
A platform-neutral tree representation of Kotlin code used by the backend to generate JVM, JS, or Native output
Explanation
The Kotlin IR backend generates a common IR tree then uses backend-specific lowerings to produce JVM bytecode, JavaScript, or LLVM IR for Native targets.
14
How does Kotlin's type projection work with in/out variance?
Correct Answer
out T (covariant projection) allows reads but not writes; in T (contravariant projection) allows writes but restricts reads — use-site variance
Explanation
fun copy(from: Array<out T>, to: Array<in T>) — from is covariant (read-only), to is contravariant (write-only). This is use-site variance, complementing declaration-site variance.
15
What is Kotlin Symbol Processing (KSP)?
Correct Answer
A lightweight annotation processing API using Kotlin's compiler APIs, replacing KAPT with faster incremental processing
Explanation
KSP (Kotlin Symbol Processing) is 2x faster than KAPT (Kotlin Annotation Processing) because it processes Kotlin's model directly, avoiding Java stub generation.
16
What are Kotlin context receivers and their design intent?
Correct Answer
An experimental feature declaring that a function requires certain receiver types in scope, enabling capabilities without inheritance
Explanation
context(Logger, Database) fun saveUser() can only be called where both Logger and Database are in scope, enabling type-safe dependency injection.
17
What is the Kotlin compiler plugin system?
Correct Answer
An API for extending the compiler with custom diagnostics, code generation, or IR transformations — used by kotlinx.serialization, Compose, etc.
Explanation
Kotlin compiler plugins hook into compilation phases. kotlinx.serialization generates serializers. Compose rewrites @Composable functions. Arrow uses plugins for compile-time validation.
18
What is Kotlin/Native and how does it differ from Kotlin/JVM?
Correct Answer
A Kotlin backend that compiles to native machine code via LLVM, enabling standalone executables without a JVM with ARC-based memory management
Explanation
Kotlin/Native uses LLVM for native compilation. Memory is managed with ARC (Automatic Reference Counting). Coroutines use a single-threaded model by default (strict immutability for sharing).
19
What is the Kotlin coroutine's low-level Continuation API?
Correct Answer
The interface underlying all coroutine suspension: Continuation<T> has resumeWith(Result<T>) which is called by the runtime to resume a suspended coroutine
Explanation
Every suspend function receives an implicit Continuation parameter. When suspended, the current state is captured. When resumeWith is called, execution resumes from that state.