Bird
0
0

What is the output of the following Kotlin code?

medium📝 Predict Output Q4 of 15
Kotlin - Data Types
What is the output of the following Kotlin code?
val ch: Char = '\u0041'
println(ch)
ACompilation error
BA
C65
D\u0041
Step-by-Step Solution
Solution:
  1. Step 1: Understand Unicode escape in Kotlin Char

    The Unicode escape \u0041 represents the character 'A' in Unicode.
  2. Step 2: Print the Char value

    Printing ch outputs the character itself, which is 'A'.
  3. Final Answer:

    A -> Option B
  4. Quick Check:

    Unicode \u0041 prints as 'A' [OK]
Quick Trick: Unicode \u0041 equals 'A' character [OK]
Common Mistakes:
MISTAKES
  • Printing the escape sequence as string
  • Printing the Unicode code as number
  • Expecting a compilation error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes