Final graded quiz: Advanced Programming in Swift :Advanced Programming in Swift (Meta iOS Developer Professional Certificate) Answers 2026
Question 1
Which of the following keywords helps create a value type?
❌ Class
❌ class
✅ struct
✅ enum
Explanation:
Swift me value types struct aur enum hote hain. class reference type hota hai.
Question 2
Which of the following code will compile?
❌
❌
✅
❌
Explanation:
-
Double = "10"❌ type mismatch -
initializer me
self.dollars = dollarsnahi likha ❌ -
Optional ko
nilassign karna valid hai ✅
Question 3
Which of the following options is a valid console output?
❌ ["coffee", "coffee", "smoothie", "smoothie", "smoothie", "blueberries"]
✅ ["blueberries", "smoothie", "coffee"]
❌ None
Explanation:Set duplicate values remove karta hai aur order guarantee nahi karta.
Question 4
Which of the following code options will compile successfully?
❌ Option 1
✅ Option 2
❌ Option 3
Explanation:
-
mutatingfunction ko call karne ke liye struct instance var hona chahiye -
non-mutating function me
self.titlechange nahi kar sakte
Question 5
Which of the following access-level modifiers is suitable for subclassing a custom data type between modules?
❌ public
❌ private
✅ open
❌ fileprivate
❌ internal
Explanation:open hi ek aisa access level hai jo module ke bahar subclassing allow karta hai.
Question 6
Which of the following code blocks is a valid protocol declaration?
❌
❌
✅
Explanation:
Protocol properties ko { get } ya { get set } specify karna zaroori hota hai.
Question 7
What will the console output?
❌ Deliver food by car
❌ No delegate found.
✅ Nothing
Explanation:delegate set hi nahi kiya gaya, aur deliverFood() call bhi nahi hua → koi output nahi.
Question 8
What will the console output?
❌
❌
❌
✅
Explanation:
-
filter { $0.count > 5 }→ strawberry, blueberry -
map→ “healthy ___” -
reduce→ prefix"Berries:\n"
Question 9
How many times will the console output Berry?
❌ 0
❌ 1
✅ 3
Explanation:Berry, Blueberry, Strawberry — sab Berry ke instance hain, isliye loop me 3 baar print hoga.
Question 10
Which of the following test methods will pass? (Select all that apply)
✅
✅
❌
✅
Explanation:
-
Empty test ❌ fail hota hai
-
Baaki teen assertions logically true hain ✅
🧾 Summary Table
| Question | Correct Answer |
|---|---|
| Q1 | struct, enum |
| Q2 | Optional initialized to nil |
| Q3 | Set with unique values |
| Q4 | var book with mutating |
| Q5 | open |
| Q6 | Property with { get } |
| Q7 | Nothing |
| Q8 | Berries + healthy strawberry & blueberry |
| Q9 | 3 |
| Q10 | 1st, 2nd, 4th |