Which of the following Kotlin literals correctly represents the number one million using underscores for better readability?
easy📝 Conceptual Q1 of 15
Kotlin - Data Types
Which of the following Kotlin literals correctly represents the number one million using underscores for better readability?
Aval million = 1_000_000
Bval million = 10_00_000
Cval million = 1000_000
Dval million = 1_00_0000
Step-by-Step Solution
Solution:
Step 1: Understand underscore placement
Underscores can be placed anywhere between digits for readability but should separate groups logically.
Step 2: Analyze each option
val million = 1_000_000 uses standard grouping (thousands), B and D use unusual groupings, C places underscore after 1000 which is allowed but less conventional.
Final Answer:
val million = 1_000_000 -> Option A
Quick Check:
Underscores separate thousands correctly [OK]
Quick Trick:Use underscores to separate thousands logically [OK]
Common Mistakes:
MISTAKES
Placing underscores at the start or end of the number
Grouping digits inconsistently
Using underscores next to decimal points
Master "Data Types" in Kotlin
9 interactive learning modes - each teaches the same concept differently