Bird
0
0

Which of the following is the correct syntax to declare an implicitly unwrapped optional String in Swift?

easy📝 Syntax Q12 of 15
Swift - Optionals
Which of the following is the correct syntax to declare an implicitly unwrapped optional String in Swift?
Avar name: !String
Bvar name: String?
Cvar name: String!
Dvar name: String
Step-by-Step Solution
Solution:
  1. Step 1: Recall syntax for implicitly unwrapped optionals

    They use an exclamation mark after the type, like String!.
  2. Step 2: Check each option

    var name: String! uses String!, which is correct syntax.
  3. Final Answer:

    var name: String! -> Option C
  4. Quick Check:

    Implicitly unwrapped optional syntax ends with ! [OK]
Quick Trick: Look for exclamation mark after type, not before [OK]
Common Mistakes:
  • Using question mark instead of exclamation mark
  • Placing exclamation mark before the type
  • Omitting the exclamation mark entirely

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Swift Quizzes