Recall & Review
beginner
What is the Kotlin
Char type used for?The
Char type in Kotlin represents a single character, such as a letter, digit, or symbol. It holds a 16-bit Unicode character.Click to reveal answer
intermediate
How does Kotlin store characters internally in the
Char type?Kotlin stores
Char as a 16-bit value representing a UTF-16 code unit, which can represent most common Unicode characters directly.Click to reveal answer
intermediate
What happens when a Unicode character requires more than 16 bits in Kotlin's
Char type?Characters outside the Basic Multilingual Plane (BMP) need two
Char values called a surrogate pair to represent one Unicode character in Kotlin.Click to reveal answer
beginner
How can you represent a Unicode character in Kotlin using escape sequences?
You can use the syntax
\uXXXX where XXXX is the 4-digit hexadecimal Unicode code unit for the character, e.g., '\u0041' for 'A'.Click to reveal answer
intermediate
Why might a Kotlin
String have a different length than the number of Unicode characters it displays?Because Kotlin
String length counts Char units (UTF-16 code units), some characters (like emojis) use two Char units, so length can be greater than visible characters.Click to reveal answer
What Kotlin type is used to store a single Unicode character?
✗ Incorrect
The
Char type stores a single Unicode character in Kotlin.How many bits does a Kotlin
Char use internally?✗ Incorrect
Kotlin
Char uses 16 bits internally, representing a UTF-16 code unit.What is a surrogate pair in Kotlin's Unicode handling?
✗ Incorrect
Surrogate pairs are two
Char values used to represent one Unicode character outside the Basic Multilingual Plane.How do you write the Unicode character 'A' using an escape sequence in Kotlin?
✗ Incorrect
The correct Unicode escape sequence in Kotlin is
\u0041 for 'A'.Why might
string.length be larger than the number of visible characters?✗ Incorrect
Some Unicode characters like emojis use two
Char units, so length counts code units, not visible characters.Explain how Kotlin's
Char type represents Unicode characters and what happens with characters outside the Basic Multilingual Plane.Think about how UTF-16 encoding works with Kotlin's Char.
You got /4 concepts.
Describe how to use Unicode escape sequences in Kotlin to represent characters and why string length might not match visible characters.
Consider how Kotlin counts characters internally versus what you see.
You got /4 concepts.