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
Which Kotlin keyword is used to declare a read-only variable that cannot be reassigned after initialization?
Answer: val
The val keyword declares a read-only (immutable reference) variable in Kotlin that cannot be reassigned, similar to final in Java.
What is a lambda expression in Kotlin?
Answer: An anonymous function that can be stored in a variable and passed as an argument
A lambda in Kotlin is an anonymous function defined with curly braces {} that can be passed as an argument or stored in a variable.
What does the Elvis operator (?:) do in Kotlin?
Answer: Returns the left-hand expression if non-null, otherwise returns the right-hand expression
The Elvis operator ?: returns the left-hand value if it is non-null; otherwise, it returns the right-hand fallback value.
What is a data class in Kotlin primarily used for?
Answer: Holding data with auto-generated equals(), hashCode(), toString(), and copy() methods
A Kotlin data class automatically generates equals(), hashCode(), toString(), copy(), and componentN() functions based on the constructor properties.
What does the safe-call operator (?.) do in Kotlin?
Answer: Calls the method only if the object is non-null, otherwise returns null
The safe-call operator ?. invokes a property or method only if the receiver is non-null; if it is null, the entire expression evaluates to null.
What is a coroutine in Kotlin?
Answer: A lightweight concurrency primitive that can be suspended and resumed without blocking a thread
A Kotlin coroutine is a concurrency design pattern that allows you to write asynchronous, non-blocking code in a sequential style using suspend functions.