B. Missing default value in $switch returns null for unmatched cases.
C. Using $gt instead of $gte is invalid syntax.
D. The $project stage cannot use $switch.
Solution
Step 1: Check $switch structure
$switch requires branches; default is optional but without it returns null when no branch matches.
Step 2: Identify missing default
The expression lacks a default field, so if score <= 80, grade is null.
Final Answer:
Missing default value in $switch returns null for unmatched cases. -> Option B
Quick Check:
$switch missing default = null [OK]
Hint: Always include default in $switch to avoid errors [OK]
Common Mistakes:
Omitting default field in $switch
Thinking $gt is invalid syntax
Misplacing branches array
5. You want to categorize products by price using $switch in an aggregation pipeline. Prices below 20 are "Cheap", 20 to 50 are "Moderate", above 50 are "Expensive". Which of the following $switch expressions correctly implements this?