Bird
0
0

What does the var keyword do in Swift?

easy📝 Conceptual Q11 of 15
Swift - Variables and Constants
What does the var keyword do in Swift?
AIt creates a variable whose value can change later.
BIt creates a constant value that cannot change.
CIt defines a function.
DIt declares a type alias.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of var

    The var keyword is used to declare variables that can be changed after they are set.
  2. Step 2: Compare with constants

    Unlike let, which creates constants, var allows the value to be updated.
  3. Final Answer:

    It creates a variable whose value can change later. -> Option A
  4. Quick Check:

    var means mutable variable [OK]
Quick Trick: Remember: var means variable, value can change [OK]
Common Mistakes:
  • Confusing var with let (constant)
  • Thinking var creates constants
  • Mixing var with function declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes