NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content

Quiz: Kotlin

Kotlin questions from real interviews as a quiz, with an explanation for every option.

29 questionsAll topicsKotlin

Try it: 5 questions

Loading…

Sample questions

  1. Which statement best describes when in Kotlin?

    • It is shorthand for if that allows only one condition and one else branch.
    • It is an expression for iterating over collection elements that always returns a list of results.
    • It is a selection construct that can be an expression or a statement and test values, types, and conditions.
    • It is a statement that compares one variable only with constants, like Java's switch.
    Full answer
  2. How do suspend functions let coroutines perform asynchronous operations without blocking a thread?

    • They create a separate thread for each operation and block it until a result is available.
    • They replace asynchronous operations with synchronous calls through runBlocking.
    • They suspend the coroutine and later resume it through a Continuation, without blocking the thread.
    • They run all operations in parallel and automatically combine their results.
    Full answer
  3. What advantages does destructuring provide in Kotlin? Select three options.

    • It assigns an object's components to separate variables in a concise declaration.
    • It lets you skip unwanted components with _.
    • It guarantees faster execution than accessing properties directly.
    • It automatically converts an object to JSON without libraries.
    • It makes it convenient to access keys and values when iterating over a Map.
    Full answer
  4. How do you overload the + operator for a custom type in Kotlin?

    • Declare an add function with the operator modifier
    • Declare a plus function without using operator
    • Declare a plus function with the operator modifier
    • Override the custom type's toString function
    Full answer
  5. Which factors can make PostgreSQL choose a Seq Scan in production and an Index Scan in dev/ft, even when the indexes are the same? Choose three.

    • Differences in data volume and the fraction of rows matching the query
    • Differences in cost settings, such as random_page_cost and seq_page_cost
    • The current CPU load and actual cache contents directly change the planner's scan choice
    • With the same indexes, PostgreSQL must choose the same plan
    • Differences in, or stale, planner statistics
    Full answer
  6. Which statements about coroutines and data streams in Kotlin are correct?

    • Dispatchers.IO is primarily intended for CPU-intensive computations.
    • A coroutine usually occupies a separate OS thread for its entire lifetime.
    • A Channel lets coroutines pass data to one another.
    • A suspend function can pause execution without blocking a thread.
    • Flow is a cold asynchronous stream that can emit multiple values.
    Full answer
  7. Select the three correct statements about PostgreSQL JSON and JSONB and their mapping in Hibernate.

    • JSONB preserves the original whitespace and key order just like JSON.
    • JSONB stores a parsed representation, does not retain the original formatting, and supports indexing.
    • Hibernate 6 cannot map JSON without a custom UserType.
    • Hibernate's JSON support depends on the version: Hibernate 6 has built-in mapping, while older versions often need third-party types.
    • JSON stores the original text, including whitespace and key order.
    Full answer
  8. What is an extension function in Kotlin?

    • A class function that uses this to access the class's private properties.
    • A method added directly to a class's source code at runtime.
    • A function declared outside a class that can be called like a method without changing the class itself.
    • An overridden method in a subclass that extends the behavior of its parent class.
    Full answer
  9. Which description of Kotlin is the most accurate?

    • An Android framework that runs only on top of Java and is not used outside mobile apps.
    • A statically typed language by JetBrains for Android, server-side, and multiplatform development.
    • A dynamically typed language for web interfaces that runs only in the browser.
    • A new version of Java designed to replace the JVM and incompatible with existing Java libraries.
    Full answer
  10. How do you declare a type alias in Kotlin, and what does it mean?

    • Use alias; it creates a new type that is incompatible with the original.
    • Use typealias; it can only be declared for functions.
    • Use typealias; it gives an existing type another name, and the two are compatible.
    • Use typealias; it creates a wrapper that must be converted to the original type.
    Full answer