This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Pipeline Operators – 1”.
1. $dayOfMonth returns the day of the month for a date as a number between ________________
a) 1 and 31
b) 1 and 30
c) 1 and 28
d) None of the mentioned
View Answer
Explanation: The $dayOfMonth expression has the following syntax: { $dayOfMonth:
2. Point out the wrong statement.
a) $second returns the seconds for a date as a number between 0 and 60 (leap seconds)
b) $minute returns the minute for a date as a number between 0 and 59
c) $millis returns the milliseconds of a date as a number between 0 and 1000
d) All of the mentioned
View Answer
Explanation: $millisecond returns the milliseconds of a date as a number between 0 and 999.
3. __________ returns the day of the year for a date as a number between 1 and 366.
a) $dayofWeekend
b) $dayOfWeek
c) $dayOfYear
d) None of the mentioned
View Answer
Explanation: The $dayOfYear expression has the following syntax:{ $dayOfYear:
4. Which of the following returns year for particular date?
a) $year
b) $yearday
c) $syearofmonth
d) None of the mentioned
View Answer
Explanation: $year returns the year for a date as a number (e.g. 2014).
5. Point out the wrong statement.
a) $weekDay returns the week number for a date as a number between 0 and 53 (leap year)
b) $cond accepts either two expressions in an ordered list or three named parameters
c) $toLower only has a well-defined behavior for strings of ASCII characters
d) None of the mentioned
View Answer
Explanation: $cond is a ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions.
6. Which of the following returns the hour for a date as a number between 0 and 23?
a) $minute
b) $hour
c) $seconds
d) All of the mentioned
View Answer
Explanation: The argument in hour statement can be any expression as long as it resolves to a date.
7. __________ returns the date as a formatted string.
a) $toString
b) $dateToString
c) $letString
d) None of the mentioned
View Answer
Explanation: $dateToString converts a date object to a string according to a user-specified format.
8. _______ result encompasses instances of undefined values or missing fields.
a) Number
b) String
c) Null
d) None of the mentioned
View Answer
Explanation: Null value does not imply zero.
9. ___________ returns either the non-null result of the first expression.
a) $Null
b) $ifNull
c) $ElseNull
d) None of the mentioned
View Answer
Explanation:$ifNull returns the result of the second expression if the first expression results in a null result.
10. __________ take as input a single expression, evaluating the expression once for each input document, and maintain their state for the group of documents.
a) Computer
b) Monitors
c) Accumulators
d) Performoner
View Answer
Explanation: Accumulators are available only for the $group stage.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check Information Technology Books
- Apply for Programming Internship
- Check MongoDB Books
- Practice Programming MCQs