Bird
0
0

What does the Kotlin expression 1..5 represent?

easy📝 Conceptual Q11 of 15
Kotlin - Operators and Expressions
What does the Kotlin expression 1..5 represent?
AAn error because ranges need parentheses
BA list containing numbers 1 and 5 only
CA function that returns 1 or 5
DA range of numbers from 1 to 5 inclusive
Step-by-Step Solution
Solution:
  1. Step 1: Understand the range operator

    The .. operator creates a range including both start and end values.
  2. Step 2: Interpret 1..5

    This means all numbers from 1 up to 5, including 1 and 5.
  3. Final Answer:

    A range of numbers from 1 to 5 inclusive -> Option D
  4. Quick Check:

    1..5 = numbers 1 to 5 [OK]
Quick Trick: Remember: .. includes both ends in Kotlin ranges [OK]
Common Mistakes:
MISTAKES
  • Thinking it creates a list instead of a range
  • Assuming it excludes the last number
  • Confusing it with a function call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes