Bird
0
0

Which Swift code correctly declares a Boolean variable indicating a premium user?

easy📝 Syntax Q3 of 15
iOS Swift - iOS Basics and Setup
Which Swift code correctly declares a Boolean variable indicating a premium user?
Avar isPremiumUser: Bool = true
Blet isPremiumUser = "true"
Cvar isPremiumUser = 1
Dlet isPremiumUser: Int = true
Step-by-Step Solution
Solution:
  1. Step 1: Understand Swift Boolean declaration

    Boolean variables use type Bool and values true or false without quotes.
  2. Step 2: Check each option

    var isPremiumUser: Bool = true correctly declares a Bool variable with true value.
  3. Final Answer:

    var isPremiumUser: Bool = true -> Option A
  4. Quick Check:

    Boolean declaration = C [OK]
Quick Trick: Use Bool type and true/false without quotes [OK]
Common Mistakes:
  • Using strings instead of Bool
  • Assigning Int to Bool variable

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More iOS Swift Quizzes