0
0
Android Kotlinmobile~10 mins

Why Kotlin is the official Android language in Android Kotlin - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a simple Kotlin function that prints a greeting.

Android Kotlin
fun greet() {
    println([1])
}
Drag options to blanks, or click blank then click option'
A"Hello, Android!"
BHello, Android!
Cprintln("Hello, Android!")
Dprint("Hello, Android!")
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the string
Trying to call print inside println
2fill in blank
medium

Complete the code to declare a Kotlin variable that cannot be changed.

Android Kotlin
val language: String = [1]
Drag options to blanks, or click blank then click option'
A"Kotlin"
BKotlin
Ckotlin
D'Kotlin'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes
Not using quotes at all
3fill in blank
hard

Fix the error in the Kotlin function that returns the length of a string.

Android Kotlin
fun lengthOf(text: String): Int {
    return text.[1]
}
Drag options to blanks, or click blank then click option'
Alength()
Bcount()
Csize()
Dlength
Attempts:
3 left
💡 Hint
Common Mistakes
Using length() with parentheses causes an error
Using size() which is not a String property
4fill in blank
hard

Fill both blanks to create a Kotlin list and print its size.

Android Kotlin
val fruits = listOf([1])
println(fruits.[2])
Drag options to blanks, or click blank then click option'
A"Apple", "Banana", "Cherry"
Bsize()
Csize
D"Apple"
Attempts:
3 left
💡 Hint
Common Mistakes
Using size() with parentheses causes error
Passing a single string instead of multiple elements
5fill in blank
hard

Fill all three blanks to create a Kotlin data class and instantiate it.

Android Kotlin
data class [1](val name: String, val age: Int)
val person = [2]([3], 30)
Drag options to blanks, or click blank then click option'
APerson
BPerson()
C"Alice"
Attempts:
3 left
💡 Hint
Common Mistakes
Using Person() as class name
Not using quotes around the string argument