MongoDB Questions and Answers – Pipeline Optimization

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

Answer: a
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

Answer: c
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

Answer: c
Explanation:$setEquals accepts two or more argument expressions.

advertisement
advertisement

4. Which of the following accepts any number of argument expression?
a) $setIntersection
b) $setDifference
c) $setEquals
d) None of the mentioned
View Answer

Answer: a
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

Answer: d
Explanation: The Boolean expression evaluates all other values as true, including non-zero numeric values and arrays.

Note: Join free Sanfoundry classes at Telegram or Youtube

6. ________ returns a set with elements that appear in any of the input sets.
a) $setIntersection
b) $setDifference
c) $setEquals
d) $setUnion
View Answer

Answer: d
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

Answer: a
Explanation:$setDifference returns a set with elements that appear in the first set but not in the second set.

advertisement

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

Answer: c
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

Answer: c
Explanation:$anyElementTrue returns true if any elements of a set evaluate to true; otherwise, returns false.

advertisement

10. $allElementsTrue returns true if no element of a set evaluates to ____________
a) false
b) true
c) 0
d) 1
View Answer

Answer: a
Explanation: An empty array returns true.

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Books in MongoDB.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.