This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Pipeline Optimization”.
1. ______ expressions ignores the duplicate entries in each input array and the order of the elements.
a) set
b) boolean
c) aggregate
d) none of the mentioned
View Answer
Explanation: If the set operation returns a set, the operation filters out duplicates in the result to output an array that contains only unique entries.
2. Point out the correct statement.
a) To avoid parsing ambiguity if the argument is a literal array, you must wrap the literal array in a $lits expression or keep the outer array that designates the argument list
b) Expressions cannot include field paths and system variables, literals, expression objects, and expression operators
c) Operator expressions are similar to functions that take arguments
d) All of the mentioned
View Answer
Explanation: In general, these expressions take an array of arguments and have the following form: { <operator>: [ <argument1>, <argument2> … ] }
3. ________ returns true if the input sets have the same distinct elements.
a) $setUnion
b) $setDifference
c) $setEquals
d) None of the mentioned
View Answer
Explanation:$setEquals accepts two or more argument expressions.
4. Which of the following accepts any number of argument expression?
a) $setIntersection
b) $setDifference
c) $setEquals
d) None of the mentioned
View Answer
Explanation:$setIntersection returns a set with elements that appear in all of the input sets.
5. Point out the wrong statement.
a) Boolean expressions evaluate their argument expressions as booleans and return a boolean as the result
b) In addition to the false boolean value, Boolean expression evaluates as false the following: null, 0, and undefined values
c) Set expressions performs set operation on arrays, treating arrays as sets
d) None of the mentioned
View Answer
Explanation: The Boolean expression evaluates all other values as true, including non-zero numeric values and arrays.
6. ________ returns a set with elements that appear in any of the input sets.
a) $setIntersection
b) $setDifference
c) $setEquals
d) $setUnion
View Answer
Explanation:$setUnion performs set operation on arrays, treating arrays as sets.
7. Which of the following performs a relative complement of the second set relative to the first?
a) $setIntersection
b) $setDifference
c) $setEquals
d) $setUnion
View Answer
Explanation:$setDifference returns a set with elements that appear in the first set but not in the second set.
8. $setIsSubset returns _______ if all elements of the first set appear in the second set, including when the first set equals the second set.
a) Null
b) True
c) False
d) None of the mentioned
View Answer
Explanation:$setIsSubset accepts exactly two argument expressions.
9. _______ accepts only single argument expression.
a) $setIsSubset
b) $bool
c) $anyElementTrue
d) None of the mentioned
View Answer
Explanation:$anyElementTrue returns true if any elements of a set evaluate to true; otherwise, returns false.
10. $allElementsTrue returns true if no element of a set evaluates to ____________
a) false
b) true
c) 0
d) 1
View Answer
Explanation: An empty array returns true.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check Information Technology Books
- Check MongoDB Books
- Apply for Programming Internship
- Practice Programming MCQs