Which function is used to launch a new coroutine in Kotlin?
runBlocking
withContext
async
launch
Which of the following functions is NOT automatically generated for a data class in Kotlin?
run()
toString()
copy()
equals()
How can you find the first element in a list that satisfies a given condition?
find()
filter().first()
first()
search()
Which operator is used for function composition in Kotlin?
compose
.
Can a sealed class be instantiated directly in Kotlin?
Yes, but only inside the same file where it's defined.
Yes, just like regular classes.
No, sealed classes cannot be instantiated directly.
Only if the sealed class is declared as open.
open
What is the primary difference between an abstract class and an interface in Kotlin?
There is no difference; they are interchangeable.
An abstract class can only inherit from one other class, while an interface can inherit from multiple.
An interface can have properties, while an abstract class cannot.
An abstract class can have constructors, while an interface cannot.
How do you throw a custom exception in Kotlin?
By using the catch block with an instance of your custom exception class.
catch
Custom exceptions cannot be thrown in Kotlin.
By using the throw keyword with an instance of your custom exception class.
throw
By using the try block with an instance of your custom exception class.
try
Which keyword is used to implement an interface in Kotlin?
uses
extends
implements
inherits
What is the purpose of runBlocking in Kotlin coroutines?
To cancel an ongoing coroutine
To switch between different dispatchers
To define a custom coroutine scope
To execute a suspending function from a non-suspending context
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 call that doesn't perform any additional computation after it returns.
A recursive function that returns its own result as the tail of a new list.
A recursive function that operates on the last element of a list.