Complete the code to declare a simple Kotlin function that returns a greeting.
fun greet() : String = [1]The function returns the string "Hello, JVM!". It must be a string literal.
Complete the code to create a Kotlin class with a primary constructor that takes a name.
class Person(val [1]: String)
The primary constructor parameter is named name to represent a person's name.
Fix the error in the Kotlin function that prints a message.
fun printMessage() {
println([1])
}The argument to println must be a string literal, so it needs quotes.
Fill both blanks to create a Kotlin map comprehension that filters entries with values greater than 10.
val filtered = mapOf(1 to 5, 2 to 15, 3 to 20).filter { it.[1] [2] 10 }
The filter checks if the value of each entry is greater than 10.
Fill all three blanks to create a Kotlin map from a list of words with their lengths, filtering words longer than 3 letters.
val words = listOf("cat", "house", "dog", "elephant") val lengths = words.associateWith { it.[1] } val filtered = lengths.filter { it.key.[2] [3] 3 }
count which is a function, not a propertykey incorrectly in associateWithThe associateWith uses it.length to get word lengths. The filter checks if the word length is greater than 3.