Bird
0
0

Which of the following is the correct way to get the Unicode code of a Char in Kotlin?

easy📝 Syntax Q12 of 15
Kotlin - Data Types
Which of the following is the correct way to get the Unicode code of a Char in Kotlin?
Aval code = 'A'.code
Bval code = 'A'.unicodeValue()
Cval code = 'A'.toInt()
Dval code = 'A'.unicode
Step-by-Step Solution
Solution:
  1. Step 1: Recall Kotlin Char Unicode property

    Kotlin provides the code property to get the Unicode integer value of a Char.
  2. Step 2: Evaluate options

    val code = 'A'.code uses code property correctly. val code = 'A'.toInt() uses toInt() which does not exist for Char. Options B and D use non-existent methods/properties.
  3. Final Answer:

    val code = 'A'.code -> Option A
  4. Quick Check:

    Use .code to get Unicode number [OK]
Quick Trick: Use .code property to get Unicode number from Char [OK]
Common Mistakes:
MISTAKES
  • Using non-existent toInt() method on Char
  • Trying non-existent methods like unicodeValue()
  • Accessing properties that don't exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes