What is destructuring in Kotlin, particularly in the context of data classes?
Converting a data class to a different data type.
Deleting specific properties from a data class instance.
Breaking down a data class instance into its constituent properties.
Destructuring is not relevant to data classes.
What is the process of a subclass providing a specific implementation for a method declared in its superclass called?
Abstracting
Encapsulating
Overloading
Overriding
Which keyword guarantees immutability for a collection in Kotlin?
var
let
const
val
What is the primary difference between an abstract class and an interface in Kotlin?
An abstract class can have constructors, while an interface cannot.
There is no difference; they are interchangeable.
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.
What is the key characteristic that distinguishes a sealed class from a regular class in Kotlin?
Sealed classes are only used for data storage.
Sealed classes cannot have constructors.
Sealed classes cannot have abstract members.
Sealed classes can only be extended within the same file.
What is the difference between any() and all() functions for collections?
any()
all()
any() and all() are interchangeable and produce the same result.
any() checks if all elements match a condition, while all() checks if at least one element matches.
any() returns the first matching element, while all() returns a list of all matching elements.
any() checks if at least one element matches a condition, while all() checks if all elements match.
Which of the following is NOT a characteristic of an abstract class in Kotlin?
It can have non-abstract methods with implementation.
It can have abstract methods without implementation.
It cannot have properties.
It cannot be instantiated.
How do you throw a custom exception in Kotlin?
By using the throw keyword with an instance of your custom exception class.
throw
Custom exceptions cannot be thrown in Kotlin.
By using the try block with an instance of your custom exception class.
try
By using the catch block with an instance of your custom exception class.
catch
Which builder function is commonly used to launch a coroutine without blocking the current thread?
launch
runBlocking
withContext
async
Which of these is NOT a common use case for sealed classes in Kotlin?
Modeling a closed type system.
Creating algebraic data types.
Representing a finite set of possible states.
Defining an extensive inheritance hierarchy.