0
0
Kotlinprogramming~10 mins

Number literal formats (underscore, hex, binary) 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 an integer with underscores for readability.

Kotlin
val number = 1[1]000_000
Drag options to blanks, or click blank then click option'
A_
B-
C.
D,
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas or dots inside number literals causes syntax errors.
Trying to use hyphens '-' inside numbers is invalid.
2fill in blank
medium

Complete the code to declare a hexadecimal number literal.

Kotlin
val hexNumber = [1]FF
Drag options to blanks, or click blank then click option'
A0x
B0o
C0d
D0b
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0b which is for binary numbers.
Using 0d or 0o which are invalid prefixes in Kotlin.
3fill in blank
hard

Fix the error in the binary number literal declaration.

Kotlin
val binaryNumber = [1]1010_1010
Drag options to blanks, or click blank then click option'
A0d
B0x
C0b
D0o
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0x which is for hexadecimal numbers.
Using 0d or 0o which are invalid prefixes.
4fill in blank
hard

Fill both blanks to create a hexadecimal number with underscores.

Kotlin
val color = [1]FF[2]00FF
Drag options to blanks, or click blank then click option'
A0x
B_
C0b
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using hyphens instead of underscores.
Using binary prefix 0b for hex numbers.
5fill in blank
hard

Fill all three blanks to declare a binary number with underscores and the correct prefix.

Kotlin
val mask = [1]1010[2]1010[3]1111
Drag options to blanks, or click blank then click option'
A0b
B_
C0x
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using hexadecimal prefix 0x for binary numbers.
Using hyphens instead of underscores.