Bird
0
0

What will be the output of this Swift code?

medium📝 Predict Output Q4 of 15
Swift - Data Types
What will be the output of this Swift code?
typealias Age = Int
let myAge: Age = 30
print(myAge)
AAge
BCompilation error
CmyAge
D30
Step-by-Step Solution
Solution:
  1. Step 1: Understand typealias usage

    The alias Age is just another name for Int, so myAge is an integer with value 30.
  2. Step 2: Predict print output

    Printing myAge outputs the integer value 30.
  3. Final Answer:

    30 -> Option D
  4. Quick Check:

    typealias does not change value, prints 30 [OK]
Quick Trick: typealias does not change data, just names [OK]
Common Mistakes:
  • Expecting alias name to print
  • Thinking it causes errors
  • Confusing variable name with type

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes