Bird
0
0

Why does Kotlin's Char type use UTF-16 encoding internally instead of UTF-32?

hard📝 Conceptual Q10 of 15
Kotlin - Data Types
Why does Kotlin's Char type use UTF-16 encoding internally instead of UTF-32?
ATo allow direct arithmetic on characters
BBecause UTF-32 is not supported in Kotlin
CTo save memory by using 16 bits per character
DBecause UTF-16 supports only ASCII characters
Step-by-Step Solution
Solution:
  1. Step 1: Understand Kotlin Char internal encoding

    Kotlin uses UTF-16 encoding for Char to balance memory usage and Unicode support.
  2. Step 2: Compare UTF-16 and UTF-32

    UTF-16 uses 16 bits per character, saving memory compared to UTF-32 which uses 32 bits per character.
  3. Final Answer:

    To save memory by using 16 bits per character -> Option C
  4. Quick Check:

    Kotlin Char uses UTF-16 to save memory [OK]
Quick Trick: UTF-16 uses less memory than UTF-32 for Char storage [OK]
Common Mistakes:
MISTAKES
  • Thinking UTF-32 is unsupported
  • Believing UTF-16 supports only ASCII
  • Confusing encoding with arithmetic capability

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes