Bird
0
0

How can you check if a Char represents a whitespace character in Kotlin?

hard📝 Application Q9 of 15
Kotlin - Data Types
How can you check if a Char represents a whitespace character in Kotlin?
Ach.isWhitespace()
Bch == ' '
Cch.isSpace()
Dch.isBlank()
Step-by-Step Solution
Solution:
  1. Step 1: Recall Kotlin Char whitespace check

    Kotlin provides isWhitespace() to check if a Char is any whitespace character (space, tab, newline, etc.).
  2. Step 2: Differentiate from other options

    ch == ' ' checks only space, isSpace() does not exist, and isBlank() is for Strings.
  3. Final Answer:

    ch.isWhitespace() -> Option A
  4. Quick Check:

    Use ch.isWhitespace() to check whitespace Char [OK]
Quick Trick: Use ch.isWhitespace() to detect any whitespace Char [OK]
Common Mistakes:
MISTAKES
  • Checking only for space character
  • Using non-existent isSpace() method
  • Confusing Char and String methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes