How do you read a line of input from the user in Kotlin?
scanner.nextLine()
input()
readLine()
read()
How can you add an element to a mutable list in Kotlin?
Using the push() function
push()
Using the append() function
append()
Using the add() function
add()
You cannot add elements to a mutable list once it's created.
What is the primary advantage of using arrays over lists in Kotlin?
Arrays are dynamically sized.
Arrays are immutable.
Arrays can store different data types.
Arrays offer better performance for certain operations.
How do you define a property in Kotlin?
Using 'var' or 'val' keyword before the variable declaration
Properties are automatically generated from constructor parameters
Using 'property' keyword
Using 'field' keyword
What is the correct way to print 'Hello, World!' to the console in Kotlin?
System.out.println("Hello, World!")
console.log("Hello, World!")
print("Hello, World!")
println("Hello, World!")
How do you exit a loop prematurely in Kotlin?
All of the above
Using the 'continue' keyword
Using the 'return' keyword
Using the 'break' keyword
Which data structure is best suited for storing a collection of unique elements in Kotlin?
List
Set
Map
Array
What is the correct way to create a range of integers from 1 to 5 (inclusive) in Kotlin?
range(1, 5)
[1, 2, 3, 4, 5]
1 to 5
1..5
What is the default visibility modifier for classes and members in Kotlin?
public
protected
internal
private
What is the output of the following Kotlin code?
fun main() { greet(name = "Alice") } fun greet(greeting: String = "Hello", name: String) { println("$greeting, $name!") }
Hello,
Alice!
Error
Hello, Alice!