Which function is used to launch a new coroutine in Kotlin?
async
launch
withContext
runBlocking
How do you replace all occurrences of a substring in a Kotlin String?
switch()
replaceAll()
replace()
substitute()
How does a suspending function differ from a regular function in Kotlin?
Suspending functions cannot return values, while regular functions can.
Suspending functions are executed on separate threads, while regular functions run on the main thread.
Suspending functions can be paused and resumed, allowing for non-blocking asynchronous operations.
Suspending functions are deprecated and should be replaced with regular functions.
Which keyword is used to implement an interface in Kotlin?
extends
implements
uses
inherits
What is the primary risk associated with using the !! operator in Kotlin?
!!
It can lead to memory leaks.
It makes the code less readable.
It slows down the execution of the program.
It can lead to NullPointerExceptions if the variable is null.
What is the process of a subclass providing a specific implementation for a method declared in its superclass called?
Abstracting
Overriding
Encapsulating
Overloading
What is a key characteristic of a higher-order function in Kotlin?
It can accept functions as parameters or return a function.
It operates on primitive data types only.
It always throws exceptions.
It cannot be used with lambda expressions.
What is the primary difference between an abstract class and an interface in Kotlin?
There is no difference; they are interchangeable.
An interface can have properties, while an abstract class cannot.
An abstract class can have constructors, while an interface cannot.
An abstract class can only inherit from one other class, while an interface can inherit from multiple.
What benefit do sealed classes provide when used with when expressions in Kotlin?
when
Enhanced performance for pattern matching.
The ability to omit the else branch in certain scenarios.
else
Sealed classes do not offer any specific benefits with when expressions.
Improved code readability.
Which operator is used for function composition in Kotlin?
compose
.