Bird
0
0

What will be the output of this Swift code?

medium📝 Predict Output Q13 of 15
Swift - Data Types
What will be the output of this Swift code?
let letter: Character = "A"
let word: String = "Apple"
print(letter)
print(word)
AError: Cannot print Character
BApple\nA
Cletter\nword
DA\nApple
Step-by-Step Solution
Solution:
  1. Step 1: Understand variable types and values

    letter is a Character with value "A"; word is a String with value "Apple".
  2. Step 2: Analyze print statements

    print(letter) outputs "A" and print(word) outputs "Apple" on separate lines.
  3. Final Answer:

    A\nApple -> Option D
  4. Quick Check:

    Print Character then String = A\nApple [OK]
Quick Trick: Print shows Character or String as text directly [OK]
Common Mistakes:
  • Confusing order of print statements
  • Thinking Character cannot be printed
  • Expecting variable names printed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes