Bird
0
0

Which of the following Swift declarations uses explicit type annotation correctly?

easy📝 Syntax Q3 of 15
Swift - Variables and Constants
Which of the following Swift declarations uses explicit type annotation correctly?
Avar name: String = "John"
Bvar name String = "John"
Cvar name = String: "John"
Dvar name = "John": String
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct syntax for explicit type annotation

    It requires a colon after the variable name, then the type, then an equal sign and value.
  2. Step 2: Evaluate each option

    Only var name: String = "John" matches this pattern correctly.
  3. Final Answer:

    var name: String = "John" -> Option A
  4. Quick Check:

    Explicit type annotation syntax = var name: Type = value [OK]
Quick Trick: Colon after variable name before type [OK]
Common Mistakes:
  • Missing colon between name and type
  • Placing type after value
  • Using colon after value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes