What is the primary risk associated with using the !! operator in Kotlin?
!!
It makes the code less readable.
It slows down the execution of the program.
It can lead to memory leaks.
It can lead to NullPointerExceptions if the variable is null.
What is the purpose of the withContext function in Kotlin coroutines?
withContext
Executes a block of code with a specified CoroutineContext.
CoroutineContext
Cancels all coroutines within a specific scope.
Creates a new CoroutineScope.
CoroutineScope
Launches a new coroutine on the main thread.
What is the purpose of runBlocking in Kotlin coroutines?
runBlocking
To switch between different dispatchers
To define a custom coroutine scope
To cancel an ongoing coroutine
To execute a suspending function from a non-suspending context
Which keyword guarantees immutability for a collection in Kotlin?
var
val
const
let
Which function is used to launch a new coroutine in Kotlin?
async
launch
What is a higher-order function in Kotlin?
A function that takes another function as a parameter or returns a function.
A function that cannot be overridden in a subclass.
A function that is declared using the inline keyword.
inline
A function that operates on collections and sequences.
What is the primary purpose of extension functions in Kotlin?
To define static methods within a class.
To override existing methods of a class.
To add new functionality to existing classes without inheriting from them.
To create abstract methods that must be implemented by subclasses.
What is the primary benefit of using polymorphism in object-oriented programming?
Flexibility and extensibility
All of the above
Improved code organization
Code reusability
What is the purpose of the finally block in a Kotlin try-catch-finally statement?
finally
try-catch-finally
To define a new custom exception class.
To execute code regardless of whether an exception is thrown.
To handle exceptions thrown in the try block.
try
To specify the type of exception that the catch block can handle.
catch
Which keyword is used to cancel an ongoing coroutine in Kotlin?
interrupt
terminate
cancel
stop