Bird
0
0

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:
  1. Step 1: Understand underscore placement

    Underscores can be placed anywhere between digits for readability but should separate groups logically.
  2. 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.
  3. Final Answer:

    val million = 1_000_000 -> Option A
  4. 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

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes