What does the ? operator signify in Kotlin?
?
It forces a variable to throw a NullPointerException.
It marks a variable as able to hold null values.
It's used for string interpolation.
It defines a constant variable.
Which Kotlin function is used to combine elements of two collections into pairs?
zip()
merge()
combine()
pair()
Can a sealed class be instantiated directly in Kotlin?
Yes, but only inside the same file where it's defined.
No, sealed classes cannot be instantiated directly.
Only if the sealed class is declared as open.
open
Yes, just like regular classes.
What happens when a coroutine encounters a suspending function?
The coroutine suspends execution at the suspending function call, allowing other work to happen on the thread.
The coroutine blocks the thread until the suspending function completes its operation.
The suspending function is executed in a separate thread, running concurrently with the coroutine.
The coroutine throws an exception because suspending functions are not allowed.
How does a suspending function differ from a regular function in Kotlin?
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 cannot return values, while regular functions can.
Suspending functions are deprecated and should be replaced with regular functions.
What is the primary risk associated with using the !! operator in Kotlin?
!!
It slows down the execution of the program.
It can lead to NullPointerExceptions if the variable is null.
It can lead to memory leaks.
It makes the code less readable.
Which keyword is used to implement an interface in Kotlin?
extends
implements
uses
inherits
Which of the following is NOT a valid way to handle a potential NullPointerException in Kotlin?
Using the Elvis operator ?: to provide a default value if the variable is null.
?:
Using the let function to execute code only if the variable is not null.
let
Using the safe call operator ?.
?.
Performing a null check using an if statement.
if
Which of the following functions is NOT automatically generated for a data class in Kotlin?
run()
copy()
toString()
equals()
Which of the following is NOT a characteristic of an abstract class in Kotlin?
It cannot be instantiated.
It can have non-abstract methods with implementation.
It cannot have properties.
It can have abstract methods without implementation.