Bird
0
0

Which of the following Kotlin expressions correctly checks if a Char is a digit?

easy📝 Conceptual Q2 of 15
Kotlin - Data Types
Which of the following Kotlin expressions correctly checks if a Char is a digit?
Ach.isNumber()
Bch.isDigit()
Cch.isDigit
DisDigit(ch)
Step-by-Step Solution
Solution:
  1. Step 1: Recall Kotlin Char methods

    Kotlin provides the isDigit() function as a member of Char to check if the character is a digit.
  2. Step 2: Identify correct syntax

    The correct usage is calling isDigit() as a function on the Char instance, like ch.isDigit().
  3. Final Answer:

    ch.isDigit() -> Option B
  4. Quick Check:

    Check digit with ch.isDigit() [OK]
Quick Trick: Use ch.isDigit() to check digits on Char [OK]
Common Mistakes:
MISTAKES
  • Using property syntax without parentheses
  • Using non-existent isNumber() method
  • Calling isDigit as a standalone function

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes