How does the 'inline' keyword optimize function calls in Kotlin?
It disables null safety checks within the function.
It creates a separate thread for the function execution.
It replaces the function call with its actual code at compile time.
It converts the function into a lambda expression automatically.
What is the purpose of the finally block in a Kotlin try-catch-finally statement?
finally
try-catch-finally
To handle exceptions thrown in the try block.
try
To execute code regardless of whether an exception is thrown.
To specify the type of exception that the catch block can handle.
catch
To define a new custom exception class.
How do you define a suspending function in Kotlin?
By annotating the function with @Coroutine
@Coroutine
By implementing the Suspendable interface
Suspendable
By using the suspend keyword in the function definition
suspend
By extending the CoroutineScope interface
CoroutineScope
How does a suspending function differ from a regular function in Kotlin?
Suspending functions cannot return values, while regular functions can.
Suspending functions can be paused and resumed, allowing for non-blocking asynchronous operations.
Suspending functions are executed on separate threads, while regular functions run on the main thread.
Suspending functions are deprecated and should be replaced with regular functions.
What is the output of the following Kotlin code?
val text = "Hello, World!" println(text.substring(7, 12))
"World"
"World!"
" Worl"
Error: Index out of bounds
Which function type represents a function that takes an Int and returns a String?
(Int) -> Unit
(Int) -> String
String(Int)
Int.() -> String
What is a key characteristic of a higher-order function in Kotlin?
It cannot be used with lambda expressions.
It always throws exceptions.
It operates on primitive data types only.
It can accept functions as parameters or return a function.
Which of the following is NOT a standard coroutine builder in Kotlin?
runBlocking
repeat
async
launch
What annotation must be added to a method in the superclass to allow it to be overridden in a subclass?
@Open
@Abstract
@Overrideable
@Override
What is the primary benefit of using polymorphism in object-oriented programming?
Flexibility and extensibility
Improved code organization
All of the above
Code reusability