Module quiz: Advanced data types :Advanced Programming in Swift (Meta iOS Developer Professional Certificate) Answers 2026
Question 1
The code below demonstrates two separate ways to declare a set.
✅ True
❌ False
Explanation: Dono syntaxes valid hain. Pehle me type inference ho raha hai, doosre me explicitly Set<String> diya gaya hai.
Question 2
What is the output of the code?
❌ [100, 100, 102, 103]
❌ [100, 101, 103, 101]
✅ [100, 102, 103, 101]
❌ [103, 102, 103, 101]
Explanation: Set unique values rakhta hai aur order guaranteed nahi hota. Union ke baad unique elements milte hain: 100, 101, 102, 103.
Question 3
What is the output of the following code?
❌ Monday is day 1 of the week
✅ Monday is day 1 of the week
Tuesday is day 2 of the week
Wednesday is day 3 of the week
Thursday is day 4 of the week
Friday is day 5 of the week
Saturday is day 6 of the week
❌ An error is thrown because only Monday has a raw value.
❌ No error but no output
Explanation: Int raw values automatically increment hote hain aur CaseIterable se loop possible hota hai.
Question 4
Which of the following can be applied to an enum? (Select all that apply)
✅ Functions
✅ Computed properties
✅ Raw values
Explanation: Swift enums kaafi powerful hote hain — methods, computed properties aur raw values sab support karte hain.
Question 5
What is the raw type of the following enum?
❌ Double
❌ String
❌ Int
✅ None of the above
Explanation: Jab raw type specify nahi hota, enum ka koi raw type nahi hota.
Question 6
What will the output of the following code be?
❌ 0
✅ 1
❌ 2
❌ None of the above
Explanation: Default raw value 0 se start hota hai → spaghetti = 0, penne = 1.
Question 7
To use allCases property in your code, which protocol must an enum conform to?
❌ Hashable
✅ CaseIterable
❌ Equatable
Explanation: allCases tabhi milta hai jab enum CaseIterable conform kare.
Question 8
What will the output of the following code be?
❌ 5
✅ 4
❌ None of the above
Explanation: Set duplicate values allow nahi karta. 1 do baar insert hua, lekin count unique = 4.
Question 9
Which of the statements is true about sets?
✅ Can only store distinct unordered values of the same type.
❌ Contains elements in a collection that don’t necessarily need to be unique.
❌ Contains elements that have key-value pairs where each key must be unique.
Explanation: Ye dictionary ka description hai, set ka nahi.
Question 10
In the scenario when there is a large amount of data expected and performance is of crucial importance, which collection should you use?
❌ Array
✅ Set
Explanation: Set fast lookup (O(1)) deta hai, jab performance critical ho.
🧾 Summary Table
| Question | Correct Answer |
|---|---|
| Q1 | True |
| Q2 | [100, 102, 103, 101] |
| Q3 | Full week output |
| Q4 | Functions, Computed properties, Raw values |
| Q5 | None of the above |
| Q6 | 1 |
| Q7 | CaseIterable |
| Q8 | 4 |
| Q9 | Distinct unordered values |
| Q10 | Set |