โ† All AAD Flashcard Decks

AAD Kotlin & Programming Fundamentals Flashcards

6 cards from real AAD practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 AAD Kotlin & Programming Fundamentals flashcards as text
  1. What is the key difference between `val` and `var` in Kotlin?

    Answer: `val` is a read-only reference that cannot be reassigned; `var` is mutable and can be reassigned

    val declares a read-only reference (like final in Java) that cannot be reassigned after initialization, while var declares a mutable variable that can be reassigned.

  2. What is an extension function in Kotlin?

    Answer: A function that adds new functionality to an existing class without modifying its source code

    An extension function lets you add new functions to an existing class without inheriting from it or modifying its source, using the syntax fun ClassName.newFunction().

  3. What does the `suspend` keyword indicate in Kotlin?

    Answer: The function can be paused and resumed within a coroutine without blocking the calling thread

    A suspend function can suspend coroutine execution at a specific point without blocking the thread, and can only be called from a coroutine or another suspend function.

  4. What is a sealed class in Kotlin?

    Answer: A class hierarchy where all subclasses are defined in the same file, enabling exhaustive when expressions

    A sealed class restricts class hierarchies so all direct subclasses must be defined in the same file, allowing exhaustive when expressions without an else branch.

  5. What is the `when` expression in Kotlin?

    Answer: A replacement for Java's switch statement that matches a value against multiple branches

    Kotlin's when expression matches a value against a series of branches and returns the value of the matching branch, serving as a more powerful switch statement.

  6. What does `lateinit` allow you to do in Kotlin?

    Answer: Declare a non-null var property without initializing it at declaration time

    lateinit allows you to declare a non-null var property and initialize it later (typically in onCreate()), avoiding null checks while deferring initialization.