Bird
0
0

In Swift, what capability does declaring a variable with var provide?

easy📝 Conceptual Q1 of 15
Swift - Variables and Constants
In Swift, what capability does declaring a variable with var provide?
AAllows the variable's value to be changed after initialization
BDeclares a constant value that cannot be changed
CDefines a function
DSpecifies a type alias
Step-by-Step Solution
Solution:
  1. Step 1: Understand var keyword

    The var keyword in Swift declares a variable whose value can be modified after it is set.
  2. Step 2: Differentiate from let

    let declares constants which cannot be changed once assigned.
  3. Final Answer:

    Allows the variable's value to be changed after initialization -> Option A
  4. Quick Check:

    Variables declared with var are mutable [OK]
Quick Trick: Use var for changeable values, let for constants [OK]
Common Mistakes:
  • Confusing var with let
  • Thinking var declares constants
  • Assuming var declares functions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes