Which of the following is NOT a characteristic of an abstract class in Kotlin?
It can have non-abstract methods with implementation.
It cannot have properties.
It cannot be instantiated.
It can have abstract methods without implementation.
Which of the following functions is NOT automatically generated for a data class in Kotlin?
run()
copy()
equals()
toString()
Which of the following is NOT a valid way to handle a potential NullPointerException in Kotlin?
Performing a null check using an if statement.
if
Using the safe call operator ?.
?.
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
What is the output of the following Kotlin code?
val text = "Hello, World!" println(text.substring(7, 12))
" Worl"
"World!"
Error: Index out of bounds
"World"
What is a higher-order function in Kotlin?
A function that is declared using the inline keyword.
inline
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 operates on collections and sequences.
In the context of recursion, what does 'tail recursion' refer to?
A recursive call that doesn't perform any additional computation after it returns.
A recursive call that happens to be at the end of the function.
A recursive function that operates on the last element of a list.
A recursive function that returns its own result as the tail of a new list.
Which class in Kotlin is used to read data from a file?
FileReader
FileBuffer
FileScanner
FileInputStream
How do you define a suspending function in Kotlin?
By implementing the Suspendable interface
Suspendable
By annotating the function with @Coroutine
@Coroutine
By extending the CoroutineScope interface
CoroutineScope
By using the suspend keyword in the function definition
suspend
When is it appropriate to use the lateinit keyword in Kotlin?
lateinit
When you want to define a constant value.
When you want to make a property nullable.
When you want to create a custom exception class.
When you want to initialize a non-nullable property later in the code, typically when you are certain it will be assigned a non-null value before its first use.
What is a potential downside of relying heavily on recursion in Kotlin?
It is not supported for complex data structures like trees and graphs.
It prevents the use of higher-order functions like 'map' and 'filter'.
It can make the code more difficult to debug and understand compared to iterative solutions.
It always leads to slower performance than iterative approaches.