All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
4330 bites
Page 193

When to use a sealed class instead of an enum?
Tests your grasp of Kotlin's type hierarchies. Use sealed class for states with associated data (e.g., Success(data)), as subclasses can have unique properties. Use enum for simple, constant states. A red flag is treating them as interchangeable.

Compare Kotlin apply and let scope functions
Apply uses this and returns receiver for configuration; let uses it and returns lambda result for null-safe transforms.

Compare and contrast Kotlin's `apply` and `let` scope functions
This tests your grasp of idiomatic Kotlin scope functions. apply uses this and returns the object, ideal for configuration. let uses it and returns the lambda result, useful for null-safe chaining.

Compare and contrast `apply` and `let` scope functions
Tests Kotlin scope function knowledge: context (this/it) & return value. apply uses this, returns the object (for config). let uses it, returns lambda result (for null-checks/transforms). Red flag: mixing up return values or use cases.

What does inline solve for higher-order functions, and what is reified?
It tests lambda overhead and type erasure. Answer: inline flattens lambdas into call sites to remove allocation and virtual calls; reified needs inline so the compiler knows the concrete type at the call site, enabling is T checks.

Explain `inline` and `reified` in Kotlin
Tests your grasp of JVM performance costs and type erasure. A great answer explains how inline avoids object allocation for lambdas, and how this enables reified to bypass type erasure for runtime checks. A red flag is just saying 'it's for performance'.

What problem does `inline` solve, and how does `reified` relate?
This tests your grasp of Kotlin compiler optimizations and JVM type erasure. Explain that inline eliminates the runtime overhead of lambda objects. Then, describe how reified leverages inlining to make generic types accessible at runtime.

Explain the difference between launch and async in Kotlin Coroutines
This tests scope behavior and side effects versus results. A strong answer says launch returns a Job for side effects, async returns a Deferred for results, and both are scope children. A red flag is using async for all tasks or ignoring exception handling.

Difference between launch and async in Kotlin Coroutines
This tests your grasp of coroutine result handling and exception propagation. Explain that launch is fire-and-forget (returns Job), while async is for results (returns Deferred). Mention async defers exceptions until await().

Explain launch vs. async in Kotlin Coroutines
Tests your grasp of structured concurrency, return values, and exceptions. launch is for fire-and-forget tasks (returns Job), while async is for tasks that produce a result (returns Deferred).

What is a suspend function in Kotlin and its compiler rules?
This tests your understanding of suspendable computations and compiler transformation. A strong answer notes non-blocking suspension, the call-from-suspend-context rule, and compiler support for pausing and resuming. A red flag is claiming they block threads.

What is a `suspend` function in Kotlin?
Tests your grasp of Kotlin's core concurrency primitive. A suspend function can pause and resume. It must be called from another suspend function or a coroutine builder.

What is a Kotlin `suspend` function and how does it work?
Tests your grasp of Kotlin's non-blocking concurrency. A great answer defines a suspend function as pausable, states its two calling rules (from another suspend function or coroutine builder), and mentions the compiler's CPS transformation.

Explain the difference between Kotlin's let, run, with, apply, and also
Group by this (apply, run, with) vs it (let, also), then by return type.

Explain Kotlin's scope functions: let, run, with, apply, also
This tests your grasp of idiomatic Kotlin and the two key differentiators: context object (this/it) and return value (object/lambda result). A great answer defines these axes, categorizes each function, and provides a clear example.

Explain Kotlin's five scope functions: let, run, with, apply, also
This tests your grasp of idiomatic Kotlin. A great answer categorizes functions by their context object (this/it) and return value (object/lambda result). Provide a clear use case for apply (object configuration).

How does Structured Concurrency handle cancellations and exceptions?
This tests scope-bound lifecycle management preventing leaks. Cover scope cancellation cascading to children, exceptions propagating up to cancel siblings, and launch or async requiring a scope. A red flag is treating coroutines as fire-and-forget threads.

Structured Concurrency in Kotlin Coroutines
Tests your understanding of coroutine lifecycles and error handling. A good answer defines the parent-child relationship, then explains how cancellation and exceptions propagate through the scope. A red flag is simply calling it a way to 'group' coroutines.

Explain Structured Concurrency in Kotlin Coroutines
Tests your grasp of coroutine lifecycle management. A great answer defines the parent-child relationship within a CoroutineScope, explains cancellation propagation, and details how exceptions cancel the entire hierarchy.

Hot vs cold Kotlin Flows and StateFlow use case
Tests grasp of flow lifecycle and collector behavior. A strong answer contrasts cold Flows, which restart per collector, with hot StateFlows broadcasting to all observers. Red flag: using Flow for UI state without citing config changes or initial value.