Practice / kt

Kotlin practice

Every Kotlin exercise, built from a topic you can open beside it.

66 exercises runs offline
kt Quiz new How do you distinguish an absent key from a present key whose value is null? Kotlin's core collection types, mutation boundaries, operation pipelines, and lazy sequences, including aliasing and key-collision traps. intermediate 1 min · from Collections kt Predict the output new Which output is produced when the terminal operation runs? Kotlin's core collection types, mutation boundaries, operation pipelines, and lazy sequences, including aliasing and key-collision traps. intermediate 2 min · from Collections kt Predict the output new What does this program print? Kotlin's core collection types, mutation boundaries, operation pipelines, and lazy sequences, including aliasing and key-collision traps. beginner 2 min · from Collections kt Review AI code new Review generated active product index Kotlin's core collection types, mutation boundaries, operation pipelines, and lazy sequences, including aliasing and key-collision traps. advanced 6 min · from Collections kt Quiz new Which operation triggers evaluation and returns a non-Sequence result? Kotlin's core collection types, mutation boundaries, operation pipelines, and lazy sequences, including aliasing and key-collision traps. beginner 1 min · from Collections kt Spot the bug new Spot the bug in the SKU index Kotlin's core collection types, mutation boundaries, operation pipelines, and lazy sequences, including aliasing and key-collision traps. intermediate 4 min · from Collections kt Quiz new Two Packet instances contain distinct byteArrayOf(1, 2) arrays. With data class Packet(va… Define data-class value semantics, understand generated equality, destructuring, and shallow copies, and avoid mutable-key, array, and secret-field traps. intermediate 1 min · from Data classes kt Quiz new What happens to an initialized class-body property when copy() creates a data-class insta… Define data-class value semantics, understand generated equality, destructuring, and shallow copies, and avoid mutable-key, array, and secret-field traps. intermediate 1 min · from Data classes kt Quiz new Which properties participate in all generated data-class members by default? Define data-class value semantics, understand generated equality, destructuring, and shallow copies, and avoid mutable-key, array, and secret-field traps. beginner 1 min · from Data classes kt Predict the output new What does this program print? Define data-class value semantics, understand generated equality, destructuring, and shallow copies, and avoid mutable-key, array, and secret-field traps. beginner 2 min · from Data classes kt Review AI code new Review generated cart snapshot Define data-class value semantics, understand generated equality, destructuring, and shallow copies, and avoid mutable-key, array, and secret-field traps. advanced 6 min · from Data classes kt Spot the bug new Spot the bug in the mutable data-class key Define data-class value semantics, understand generated equality, destructuring, and shallow copies, and avoid mutable-key, array, and secret-field traps. intermediate 4 min · from Data classes kt Quiz new What does val age: Int by values guarantee when values has type Map<String, Any?>? Move Kotlin getter and setter logic into reusable delegates, with precise guidance for lazy, observable, custom delegates, shared state, and thread safety. intermediate 1 min · from Delegated properties kt Predict the output new What does this program print? Move Kotlin getter and setter logic into reusable delegates, with precise guidance for lazy, observable, custom delegates, shared state, and thread safety. beginner 2 min · from Delegated properties kt Predict the output new What does this program print after the rejected assignment? Move Kotlin getter and setter logic into reusable delegates, with precise guidance for lazy, observable, custom delegates, shared state, and thread safety. beginner 2 min · from Delegated properties kt Quiz new When is provideDelegate() called for a delegated member property? Move Kotlin getter and setter logic into reusable delegates, with precise guidance for lazy, observable, custom delegates, shared state, and thread safety. intermediate 1 min · from Delegated properties kt Review AI code new Review generated account field delegate Move Kotlin getter and setter logic into reusable delegates, with precise guidance for lazy, observable, custom delegates, shared state, and thread safety. advanced 6 min · from Delegated properties kt Spot the bug new Spot the bug in the singleton delegate Move Kotlin getter and setter logic into reusable delegates, with precise guidance for lazy, observable, custom delegates, shared state, and thread safety. intermediate 4 min · from Delegated properties kt Quiz new Two nested receiver types carry the same DSL marker. How can the inner block access an ou… Design Kotlin internal DSLs with lambdas with receivers, type-safe builders, explicit scope control, and verifiable result boundaries. intermediate 1 min · from DSLs kt Predict the output new What does this receiver-based builder print? Design Kotlin internal DSLs with lambdas with receivers, type-safe builders, explicit scope control, and verifiable result boundaries. beginner 2 min · from DSLs kt Review AI code new Review generated database DSL Design Kotlin internal DSLs with lambdas with receivers, type-safe builders, explicit scope control, and verifiable result boundaries. advanced 6 min · from DSLs kt Spot the bug new Spot the bug in the menu snapshot Design Kotlin internal DSLs with lambdas with receivers, type-safe builders, explicit scope control, and verifiable result boundaries. intermediate 4 min · from DSLs kt Quiz new What does a staged builder guarantee when only the final stage can produce the result? Design Kotlin internal DSLs with lambdas with receivers, type-safe builders, explicit scope control, and verifiable result boundaries. intermediate 1 min · from DSLs kt Quiz new A SQL DSL accepts a String and interpolates it into a query. What does Kotlin type checki… Design Kotlin internal DSLs with lambdas with receivers, type-safe builders, explicit scope control, and verifiable result boundaries. intermediate 1 min · from DSLs kt Quiz new A type and an imported extension both define render() with compatible signatures. Which d… Add functions and computed properties to existing types with receiver syntax, then reason about static resolution, member precedence, nullability, and scope. beginner 1 min · from Extensions kt Predict the output new What does the direct call do differently from the safe call? Add functions and computed properties to existing types with receiver syntax, then reason about static resolution, member precedence, nullability, and scope. intermediate 2 min · from Extensions kt Predict the output new What does this program print? Add functions and computed properties to existing types with receiver syntax, then reason about static resolution, member precedence, nullability, and scope. intermediate 2 min · from Extensions kt Review AI code new Review generated account label extension Add functions and computed properties to existing types with receiver syntax, then reason about static resolution, member precedence, nullability, and scope. advanced 6 min · from Extensions kt Spot the bug new Spot the bug in the retryCount property Add functions and computed properties to existing types with receiver syntax, then reason about static resolution, member precedence, nullability, and scope. beginner 4 min · from Extensions kt Quiz new Why omit else from a when expression that lists every member of an enum? Learn Kotlin's read-only references, static types, null safety, expressions, control flow, and function-call boundaries. intermediate 1 min · from Kotlin fundamentals kt Quiz new count has type Int. Which expression passes it to fun store(value: Long)? Learn Kotlin's read-only references, static types, null safety, expressions, control flow, and function-call boundaries. beginner 1 min · from Kotlin fundamentals kt Predict the output new What does this program print? Learn Kotlin's read-only references, static types, null safety, expressions, control flow, and function-call boundaries. beginner 2 min · from Kotlin fundamentals kt Review AI code new Review generated invoice total Learn Kotlin's read-only references, static types, null safety, expressions, control flow, and function-call boundaries. advanced 6 min · from Kotlin fundamentals kt Spot the bug new Spot the bug in the name-length function Learn Kotlin's read-only references, static types, null safety, expressions, control flow, and function-call boundaries. beginner 4 min · from Kotlin fundamentals kt Quiz new Which use site normally requires a boxed representation for @JvmInline value class UserId… Model single-value domain types with `@JvmInline value class`, including JVM representation, boxing boundaries, validation, and Java interop. intermediate 1 min · from Inline value classes kt Quiz new What is the dependable way to publish a Java-callable function whose Kotlin API accepts a… Model single-value domain types with `@JvmInline value class`, including JVM representation, boxing boundaries, validation, and Java interop. advanced 1 min · from Inline value classes kt Predict the output new What does this program print? Model single-value domain types with `@JvmInline value class`, including JVM representation, boxing boundaries, validation, and Java interop. beginner 2 min · from Inline value classes kt Review AI code new Review generated API token wrapper Model single-value domain types with `@JvmInline value class`, including JVM representation, boxing boundaries, validation, and Java interop. advanced 6 min · from Inline value classes kt Spot the bug new Spot the bug in the value-class map key Model single-value domain types with `@JvmInline value class`, including JVM representation, boxing boundaries, validation, and Java interop. intermediate 4 min · from Inline value classes kt Quiz new Which type means “an optional function that accepts a String and returns an Int”? Lambda expressions turn behavior into statically typed values; learn function types, capture, receivers, return control, and JVM boundaries. beginner 1 min · from Lambda expressions kt Predict the output new What does this program print? Lambda expressions turn behavior into statically typed values; learn function types, capture, receivers, return control, and JVM boundaries. beginner 2 min · from Lambda expressions kt Predict the output new Which lines are printed when the trailing lambda is passed? Lambda expressions turn behavior into statically typed values; learn function types, capture, receivers, return control, and JVM boundaries. intermediate 2 min · from Lambda expressions kt Review AI code new Review generated event registry Lambda expressions turn behavior into statically typed values; learn function types, capture, receivers, return control, and JVM boundaries. advanced 6 min · from Lambda expressions kt Spot the bug new Spot the bug in callback index capture Lambda expressions turn behavior into statically typed values; learn function types, capture, receivers, return control, and JVM boundaries. intermediate 4 min · from Lambda expressions kt Quiz new Which type allows both the list itself and each element to be null? Model missing values with nullable types, smart casts, safe calls, and Elvis, then keep NPEs out of Java and generated-code boundaries. beginner 1 min · from Null safety kt Quiz new An unannotated Java method returns a platform String type. Which first step keeps the Kot… Model missing values with nullable types, smart casts, safe calls, and Elvis, then keep NPEs out of Java and generated-code boundaries. intermediate 1 min · from Null safety kt Predict the output new What does this program print? Model missing values with nullable types, smart casts, safe calls, and Elvis, then keep NPEs out of Java and generated-code boundaries. beginner 2 min · from Null safety kt Review AI code new Review generated customer importer Model missing values with nullable types, smart casts, safe calls, and Elvis, then keep NPEs out of Java and generated-code boundaries. advanced 6 min · from Null safety kt Spot the bug new Spot the bug in the changing host getter Model missing values with nullable types, smart casts, safe calls, and Elvis, then keep NPEs out of Java and generated-code boundaries. intermediate 4 min · from Null safety kt Quiz new A family of parsers needs one shared constructor-owned cache and a fixed parse template. … Build clear object boundaries with classes, interfaces, inheritance, and composition; understand Kotlin's final defaults, dispatch, and construction order. intermediate 1 min · from Object-oriented programming kt Quiz new BillingService needs to send audit records through interchangeable destinations. Which re… Build clear object boundaries with classes, interfaces, inheritance, and composition; understand Kotlin's final defaults, dispatch, and construction order. intermediate 1 min · from Object-oriented programming kt Quiz new Which declaration permits a subclass to replace calculate()? Build clear object boundaries with classes, interfaces, inheritance, and composition; understand Kotlin's final defaults, dispatch, and construction order. beginner 1 min · from Object-oriented programming kt Predict the output new What does this program print? Build clear object boundaries with classes, interfaces, inheritance, and composition; understand Kotlin's final defaults, dispatch, and construction order. beginner 2 min · from Object-oriented programming kt Review AI code new Review generated notification service Build clear object boundaries with classes, interfaces, inheritance, and composition; understand Kotlin's final defaults, dispatch, and construction order. advanced 6 min · from Object-oriented programming kt Spot the bug new Spot the bug in the account balance Build clear object boundaries with classes, interfaces, inheritance, and composition; understand Kotlin's final defaults, dispatch, and construction order. beginner 4 min · from Object-oriented programming kt Quiz new For value of type String?, which statement about value.let and value?.let is correct? Choose among Kotlin's let, run, with, apply, and also by receiver and return value, without nullable, nested-receiver, or chain-type mistakes. intermediate 1 min · from Scope functions kt Predict the output new What does lookup("known") print when the receiver exists but the let block returns null? Choose among Kotlin's let, run, with, apply, and also by receiver and return value, without nullable, nested-receiver, or chain-type mistakes. intermediate 2 min · from Scope functions kt Predict the output new What does this program print? Choose among Kotlin's let, run, with, apply, and also by receiver and return value, without nullable, nested-receiver, or chain-type mistakes. beginner 2 min · from Scope functions kt Review AI code new Review generated signup registry Choose among Kotlin's let, run, with, apply, and also by receiver and return value, without nullable, nested-receiver, or chain-type mistakes. advanced 6 min · from Scope functions kt Spot the bug new Spot the bug in the nested it receiver Choose among Kotlin's let, run, with, apply, and also by receiver and return value, without nullable, nested-receiver, or chain-type mistakes. intermediate 4 min · from Scope functions kt Quiz new Which declaration best models one implementation that is both a known Failure variant and… Model finite states with restricted hierarchies, use exhaustive when to catch new cases, and choose correctly among sealed classes, interfaces, and enums. intermediate 1 min · from Sealed classes and interfaces kt Quiz new Where may a direct subclass of a sealed class be declared in Kotlin 2.4.10? Model finite states with restricted hierarchies, use exhaustive when to catch new cases, and choose correctly among sealed classes, interfaces, and enums. intermediate 1 min · from Sealed classes and interfaces kt Predict the output new What does this program print? Model finite states with restricted hierarchies, use exhaustive when to catch new cases, and choose correctly among sealed classes, interfaces, and enums. beginner 2 min · from Sealed classes and interfaces kt Predict the output new What does this program print? Model finite states with restricted hierarchies, use exhaustive when to catch new cases, and choose correctly among sealed classes, interfaces, and enums. intermediate 2 min · from Sealed classes and interfaces kt Review AI code new Review a generated payment hierarchy Model finite states with restricted hierarchies, use exhaustive when to catch new cases, and choose correctly among sealed classes, interfaces, and enums. advanced 6 min · from Sealed classes and interfaces kt Spot the bug new Spot the bug in delivery state labeling Model finite states with restricted hierarchies, use exhaustive when to catch new cases, and choose correctly among sealed classes, interfaces, and enums. intermediate 4 min · from Sealed classes and interfaces