Which of these is NOT a common use case for sealed classes in Kotlin?
Defining an extensive inheritance hierarchy.
Representing a finite set of possible states.
Creating algebraic data types.
Modeling a closed type system.
Which function type represents a function that takes an Int and returns a String?
String(Int)
(Int) -> String
(Int) -> Unit
Int.() -> String
What is a higher-order function in Kotlin?
A function that is declared using the inline keyword.
inline
A function that cannot be overridden in a subclass.
A function that operates on collections and sequences.
A function that takes another function as a parameter or returns a function.
In the context of recursion, what does 'tail recursion' refer to?
A recursive call that happens to be at the end of the function.
A recursive function that returns its own result as the tail of a new list.
A recursive call that doesn't perform any additional computation after it returns.
A recursive function that operates on the last element of a list.
What is the role of a CoroutineContext?
CoroutineContext
Manages the execution order of coroutines
Provides information and settings for a coroutine
Handles exceptions thrown within a coroutine
Stores the data shared between coroutines
What is the primary risk associated with using the !! operator in Kotlin?
!!
It slows down the execution of the program.
It can lead to memory leaks.
It makes the code less readable.
It can lead to NullPointerExceptions if the variable is null.
Which class in Kotlin is used to read data from a file?
FileInputStream
FileReader
FileBuffer
FileScanner
Which of the following is a valid way to define an extension function for the String class in Kotlin?
extension fun String.newMethod() {}
String.fun newMethod() {}
fun String.newMethod() {}
fun newMethod(str: String) {}
Which keyword guarantees immutability for a collection in Kotlin?
let
var
val
const
What is the purpose of runBlocking in Kotlin coroutines?
runBlocking
To execute a suspending function from a non-suspending context
To cancel an ongoing coroutine
To define a custom coroutine scope
To switch between different dispatchers