0
0
Kotlinprogramming~10 mins

What is Kotlin - Interactive Quiz & Practice

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

Complete the code to print a greeting in Kotlin.

Kotlin
fun main() {
    println([1])
}
Drag options to blanks, or click blank then click option'
A"Hello, Kotlin!"
BHello, Kotlin!
Cprint("Hello, Kotlin!")
Decho "Hello, Kotlin!"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the quotes around the text.
Using print instead of println without parentheses.
2fill in blank
medium

Complete the code to declare a variable holding the number 10.

Kotlin
fun main() {
    val number: Int = [1]
    println(number)
}
Drag options to blanks, or click blank then click option'
A10
BNumber
Cten
D"10"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number inside quotes, making it a string.
Using a word instead of a number.
3fill in blank
hard

Fix the error in the function declaration by completing the blank.

Kotlin
fun greet() : [1] {
    return "Hello"
}
Drag options to blanks, or click blank then click option'
AInt
BString
CUnit
Dvoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using Unit or void which mean no return value.
Using Int which is for numbers.
4fill in blank
hard

Fill both blanks to create a list of numbers from 1 to 5.

Kotlin
fun main() {
    val numbers = listOf([1], [2], 3, 4, 5)
    println(numbers)
}
Drag options to blanks, or click blank then click option'
A1
B2
C"1"
D"2"
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers, making them strings.
Using wrong numbers or text.
5fill in blank
hard

Fill all three blanks to create a function that adds two numbers and returns the result.

Kotlin
fun add([1]: Int, [2]: Int) : [3] {
    return a + b
}
Drag options to blanks, or click blank then click option'
Aa
Bb
CInt
DString
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names that don't match the return statement.
Using String as return type instead of Int.