Bird
0
0

Which of the following Swift statements is syntactically correct and uses type inference?

easy📝 Syntax Q3 of 15
Swift - Variables and Constants
Which of the following Swift statements is syntactically correct and uses type inference?
Avar 2ndValue = 5
Blet message: = "Hello"
Cvar score = 100
Dlet isReady = ?
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax correctness

    var score = 100 declares a variable with inferred Int type correctly.
  2. Step 2: Identify syntax errors in other options

    let message: = "Hello" has misplaced colon, var 2ndValue = 5 starts variable name with digit, let isReady = ? uses invalid assignment.
  3. Final Answer:

    var score = 100 -> Option C
  4. Quick Check:

    Correct syntax with type inference = var score = 100 [OK]
Quick Trick: Variable names must start with letters; no misplaced colons [OK]
Common Mistakes:
  • Starting variable names with digits
  • Misplacing colons in declarations
  • Using invalid assignment symbols

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes