Bird
0
0

What will be the output of this Swift code?

medium๐Ÿ“ Predict Output Q5 of 15
Swift - Data Types
What will be the output of this Swift code?
let emoji: Character = "๐Ÿ˜Š"
print(emoji)
A๐Ÿ˜Š
B"๐Ÿ˜Š"
COptional("๐Ÿ˜Š")
DError: Cannot print Character
Step-by-Step Solution
Solution:
  1. Step 1: Understand Character with emoji

    Swift Character supports Unicode, including emojis, so emoji holds the emoji character.
  2. Step 2: Printing a Character

    Printing a Character prints the character itself without quotes or Optional wrapper.
  3. Final Answer:

    ๐Ÿ˜Š -> Option A
  4. Quick Check:

    Character prints as-is, even emojis [OK]
Quick Trick: Characters print directly, emojis included [OK]
Common Mistakes:
  • Expecting quotes around printed character
  • Thinking emoji is unsupported in Character
  • Confusing optional with direct print

Want More Practice?

15+ quiz questions ยท All difficulty levels ยท Free

Free Signup - Practice All Questions
More Swift Quizzes