What role does a CoroutineScope play in managing coroutines?
CoroutineScope
Converts blocking code to asynchronous operations.
Executes suspending functions synchronously.
Defines the lifetime of a group of coroutines.
Handles exceptions thrown within threads.
In Kotlin, what keyword is used to mark a class as inheritable?
open
extends
derivable
inherit
Which function is used to launch a new coroutine in Kotlin?
launch
withContext
async
runBlocking
How does the 'inline' keyword optimize function calls in Kotlin?
It disables null safety checks within the function.
It creates a separate thread for the function execution.
It replaces the function call with its actual code at compile time.
It converts the function into a lambda expression automatically.
What does the ? operator signify in Kotlin?
?
It defines a constant variable.
It's used for string interpolation.
It marks a variable as able to hold null values.
It forces a variable to throw a NullPointerException.
Which keyword is used to cancel an ongoing coroutine in Kotlin?
terminate
stop
interrupt
cancel
What is destructuring in Kotlin, particularly in the context of data classes?
Deleting specific properties from a data class instance.
Breaking down a data class instance into its constituent properties.
Converting a data class to a different data type.
Destructuring is not relevant to data classes.
What is the primary difference between an abstract class and an interface in Kotlin?
An interface can have properties, while an abstract class cannot.
An abstract class can only inherit from one other class, while an interface can inherit from multiple.
There is no difference; they are interchangeable.
An abstract class can have constructors, while an interface cannot.
What is a potential downside of relying heavily on recursion in Kotlin?
It always leads to slower performance than iterative approaches.
It can make the code more difficult to debug and understand compared to iterative solutions.
It is not supported for complex data structures like trees and graphs.
It prevents the use of higher-order functions like 'map' and 'filter'.
How do you create a copy of a data class instance with modified properties in Kotlin?
Data classes are immutable and cannot be copied.
Using the clone() method.
clone()
Using the copy() method and specifying the properties to change.
copy()
By manually assigning each property to a new instance.