Bird
0
0

In Kotlin, which when condition correctly checks if a variable num is NOT in the range 5 to 15?

easy📝 Conceptual Q2 of 15
Kotlin - Control Flow as Expressions
In Kotlin, which when condition correctly checks if a variable num is NOT in the range 5 to 15?
Anum outside 5..15
Bnum not in 5..15
Cnum not within 5..15
Dnum !in 5..15
Step-by-Step Solution
Solution:
  1. Step 1: Recall Kotlin syntax for range exclusion

    Kotlin uses !in to check if a value is NOT inside a range.
  2. Step 2: Verify the correct syntax

    The correct syntax is num !in 5..15. Other options are invalid Kotlin syntax.
  3. Final Answer:

    num !in 5..15 -> Option D
  4. Quick Check:

    Use !in to check exclusion from range = C [OK]
Quick Trick: Use !in to check if value is outside a range [OK]
Common Mistakes:
MISTAKES
  • Writing 'not in' instead of '!in'
  • Using 'outside' or 'not within' which are invalid
  • Confusing syntax with other languages

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes