Bird
0
0

What will be the output of this Swift code?

medium📝 Predict Output Q5 of 15
Swift - Variables and Constants
What will be the output of this Swift code?
let name = "Alice"
print(name)
ACompile-time error
BAlice
Cnil
Dname
Step-by-Step Solution
Solution:
  1. Step 1: Understand constant declaration

    The constant name is assigned the string "Alice".
  2. Step 2: Print the constant value

    Printing name outputs the string value "Alice".
  3. Final Answer:

    Alice -> Option B
  4. Quick Check:

    Printing let constant outputs its value [OK]
Quick Trick: Print constant name to see its assigned value [OK]
Common Mistakes:
  • Printing variable name instead of value
  • Expecting nil for uninitialized constants
  • Confusing compile error with correct code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes