What is the purpose of the 'when' statement in Kotlin?
To execute a block of code repeatedly
To declare a variable
To define a function
To perform different actions based on different conditions
What is the difference between emptyList() and mutableListOf() in Kotlin?
emptyList()
mutableListOf()
emptyList() creates a list with a fixed size, while mutableListOf() creates a list with dynamic size.
There is no difference; both are interchangeable.
emptyList() creates an empty immutable list, while mutableListOf() creates an empty mutable list.
emptyList() is used for numbers, while mutableListOf() is used for strings.
What are the two types of properties in Kotlin?
Static and dynamic
Stored and computed
Constant and variable
Public and private
How do you read a line of input from the user in Kotlin?
read()
scanner.nextLine()
readLine()
input()
Which data type represents a whole number in Kotlin?
Boolean
Int
String
Float
Which keyword is used to declare a class in Kotlin?
struct
object
interface
class
What is the correct syntax to define a function named 'greet' that takes no arguments and returns nothing in Kotlin?
fun greet() {}
function greet() {}
def greet() {}
void greet() {}
What happens when you try to access a non-existent key in a Kotlin map?
It returns a default value.
It throws an IndexOutOfBoundsException.
It throws a NullPointerException.
It returns null.
Which of the following is NOT a characteristic of a Kotlin List?
Provides indexed access to elements.
Can store elements of different data types.
Maintains the order of elements.
Allows duplicate elements.
What is the output of the following Kotlin code snippet?
val x = 5 if (x > 10) { println("Greater than 10") } else if (x < 10) { println("Less than 10") } else { println("Equal to 10") }
Greater than 10
Equal to 10
The code will not compile
Less than 10