Bird
0
0

Which of the following is a valid way to write the number one million in Kotlin using underscores for readability?

easy📝 Conceptual Q11 of 15
Kotlin - Data Types
Which of the following is a valid way to write the number one million in Kotlin using underscores for readability?
A<code>1__000000</code>
B<code>1000_000_</code>
C<code>10__00_000</code>
D<code>1_000_000</code>
Step-by-Step Solution
Solution:
  1. Step 1: Understand underscore usage in Kotlin numbers

    Kotlin allows underscores between digits to improve readability, but they must not be consecutive, leading, or trailing.
  2. Step 2: Check each option for correct underscore placement

    1_000_000 uses single underscores separating groups of three digits correctly. A has consecutive underscores (invalid). B has trailing underscore (invalid). C has consecutive underscores (invalid).
  3. Final Answer:

    1_000_000 -> Option D
  4. Quick Check:

    Underscores separate digits properly = 1_000_000 [OK]
Quick Trick: Use single underscores between digit groups only [OK]
Common Mistakes:
MISTAKES
  • Using double underscores
  • Placing underscores at start or end
  • Trailing underscores

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes