What is a key characteristic of a higher-order function in Kotlin?
It operates on primitive data types only.
It cannot be used with lambda expressions.
It always throws exceptions.
It can accept functions as parameters or return a function.
When might it be more appropriate to choose an iterative approach over recursion in Kotlin?
When the problem involves manipulating immutable data structures.
When the recursive solution would be significantly more readable and concise.
When the function needs to be inlined for performance optimization.
When the problem can be solved more efficiently with loops, especially for large inputs.
How do you create a copy of a data class instance with modified properties in Kotlin?
Using the copy() method and specifying the properties to change.
copy()
Data classes are immutable and cannot be copied.
By manually assigning each property to a new instance.
Using the clone() method.
clone()
What is the key characteristic that distinguishes a sealed class from a regular class in Kotlin?
Sealed classes are only used for data storage.
Sealed classes cannot have constructors.
Sealed classes can only be extended within the same file.
Sealed classes cannot have abstract members.
What is the primary risk associated with using the !! operator in Kotlin?
!!
It makes the code less readable.
It can lead to NullPointerExceptions if the variable is null.
It can lead to memory leaks.
It slows down the execution of the program.
How can you find the first element in a list that satisfies a given condition?
filter().first()
search()
find()
first()
What is the role of a CoroutineContext?
CoroutineContext
Provides information and settings for a coroutine
Handles exceptions thrown within a coroutine
Manages the execution order of coroutines
Stores the data shared between coroutines
Which of the following is NOT a standard coroutine builder in Kotlin?
repeat
async
launch
runBlocking
When is it appropriate to use the lateinit keyword in Kotlin?
lateinit
When you want to make a property nullable.
When you want to create a custom exception class.
When you want to initialize a non-nullable property later in the code, typically when you are certain it will be assigned a non-null value before its first use.
When you want to define a constant value.
What keyword is used to call the superclass implementation of an overridden method from within the subclass?
base
super
this
parent