0
0
Kotlinprogramming~10 mins

Explicit type declaration in Kotlin - Interactive Code Practice

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

Complete the code to declare a variable with an explicit type.

Kotlin
val name: [1] = "Alice"
Drag options to blanks, or click blank then click option'
ABoolean
BInt
CString
DDouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int or Boolean for text values.
Forgetting to specify the type explicitly.
2fill in blank
medium

Complete the code to declare a variable with explicit integer type.

Kotlin
var age: [1] = 30
Drag options to blanks, or click blank then click option'
AInt
BDouble
CString
DBoolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using Double or String for whole numbers.
Not matching the type with the assigned value.
3fill in blank
hard

Fix the error in the explicit type declaration.

Kotlin
val isActive: [1] = true
Drag options to blanks, or click blank then click option'
AString
BBoolean
CInt
DDouble
Attempts:
3 left
💡 Hint
Common Mistakes
Using String type for Boolean values.
Assigning Boolean values as text strings.
4fill in blank
hard

Fill both blanks to declare a variable with explicit Double type and assign a decimal value.

Kotlin
var price: [1] = [2]
Drag options to blanks, or click blank then click option'
ADouble
B30
C19.99
DInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using Int type for decimal numbers.
Assigning whole numbers instead of decimals.
5fill in blank
hard

Fill all three blanks to declare a variable with explicit type and assign a value correctly.

Kotlin
val [1]: [2] = [3]
Drag options to blanks, or click blank then click option'
AisAvailable
BBoolean
Cfalse
Dprice
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect variable names.
Assigning Boolean values as strings.
Mismatch between type and assigned value.