Database - MongoDB MCQ Questions and Answers

Test your knowledge of Database - [MongoDB] section with these interactive multiple-choice questions.

« First 7 8 9 10 Last »
« Previous Page Next Page »

161. Which command configures a MongoDB Atlas Search analyzer?

  • a) Atlas UI/API only
  • b) db.createAnalyzer()
  • c) mongod --analyzer
  • d) db.analyzer.setup()
Answer: A - Analyzers (language processors for text search) are configured through Atlas interface.

162. What is the purpose of the $dayOfWeek operator?

  • a) Returns weekday number (1=Sunday-7=Saturday)
  • b) Groups by workdays
  • c) Calculates business days
  • d) Validates calendar dates
Answer: A - { $dayOfWeek: "$date" } extracts the ISO day of week (1-7).

163. Which method enables MongoDB's SNMP monitoring?

  • a) mongod --snmp
  • b) db.enableSNMP()
  • c) db.snmp.start()
  • d) Requires configuration file
Answer: D - SNMP requires net.snmp settings in mongod.conf or --snmp command-line option.

164. What does the $isoDayOfWeek operator return?

  • a) Weekday number (1=Monday-7=Sunday)
  • b) ISO week date
  • c) Day number in ISO format
  • d) Validates ISO dates
Answer: A - { $isoDayOfWeek: "$date" } follows ISO 8601 (Monday=1 to Sunday=7).

165. Which operator performs case-sensitive string comparison?

  • a) $strcasecmp
  • b) $cmp
  • c) $eq
  • d) All of the above
Answer: B - $cmp performs case-sensitive comparison, while $strcasecmp is case-insensitive.

166. What is the purpose of the $count stage?

  • a) Returns document count
  • b) Creates counters
  • c) Limits result size
  • d) Groups by quantity
Answer: A - { $count: "total" } adds a field with the pipeline's document count.

167. Which command lists all MongoDB's current locks?

  • a) db.currentOp(true).inprog
  • b) db.locks()
  • c) show locks
  • d) db.serverStatus().locks
Answer: A - currentOp(true) shows operations with their lock details.

168. What does the $substrCP operator do?

  • a) Extracts substring by code points
  • b) Counts Unicode characters
  • c) Validates UTF-8
  • d) Splits code pages
Answer: A - { $substrCP: ["MongoDB", 0, 3] } returns "Mon" (handles multi-byte chars correctly).

169. Which method returns MongoDB's query executor stats?

  • a) db.serverStatus().metrics.queryExecutor
  • b) db.queryStats()
  • c) mongod --queryMetrics
  • d) db.getQueryExec()
Answer: A - Query executor metrics are nested in serverStatus() output.

170. What is the purpose of the $dateFromString operator with timezone?

  • a) Parses timezone-aware date strings
  • b) Converts between timezones
  • c) Validates timezone offsets
  • d) Stores UTC timestamps
Answer: A - { $dateFromString: { dateString: "text", timezone: "America/New_York" } }.

171. Which operator checks if a field is missing or null?

  • a) $ifNull
  • b) $exists: false
  • c) $or: [ {field:null}, {field:{$exists:false}} ]
  • d) $missing
Answer: C - Requires combining $exists and null checks (no single operator).

172. What does the $strLenCP operator return?

  • a) String length in code points
  • b) Byte count
  • c) UTF-8 validity
  • d) Character encoding
Answer: A - { $strLenCP: "MongoDB" } returns 7 (counts Unicode chars, not bytes).

173. Which command lists all Atlas Search indexes?

  • a) db.collection.getSearchIndexes()
  • b) show searchIndexes
  • c) db.listSearchIndexes()
  • d) db.search.indexes()
Answer: A - getSearchIndexes() returns Atlas Search index configurations.

174. What is the purpose of the $toLower operator?

  • a) Converts string to lowercase
  • b) Normalizes text
  • c) Maps to lowercase keys
  • d) Filters case-insensitive
Answer: A - { $toLower: "MongoDB" } returns "mongodb".

175. Which operator checks if arrays have same elements?

  • a) $setEquals
  • b) $arrayEqual
  • c) $sameElements
  • d) $identical
Answer: A - { $setEquals: [array1, array2] } ignores element order.

176. What does the $abs operator do?

  • a) Returns absolute value
  • b) Calculates precision
  • c) Validates numbers
  • d) Abstracts values
Answer: A - { $abs: -5 } returns 5.

177. Which method returns MongoDB's storage engine stats?

  • a) db.serverStatus().storageEngine
  • b) db.storageStats()
  • c) mongod --storageDetails
  • d) db.engineInfo()
Answer: A - WiredTiger or inMemory engine metrics are in serverStatus().

178. What is the purpose of the $toString operator?

  • a) Converts value to string
  • b) Validates string format
  • c) Serializes objects
  • d) Casts to text
Answer: A - { $toString: 42 } returns "42".

179. Which operator checks if value is a number?

  • a) $isNumber
  • b) $type with numeric types
  • c) $number
  • d) $numeric
Answer: B - Use { $type: ["$field", "number"] } or check specific numeric types.

180. What does the $toInt operator do?

  • a) Converts value to integer
  • b) Truncates decimals
  • c) Validates integers
  • d) Rounds numbers
Answer: A - { $toInt: "42" } returns 42 (errors on non-numeric strings).
« First 7 8 9 10 Last »
« Previous Page Next Page »

MongoDB MCQs - Master NoSQL Database Concepts | PCBooks

🚀 Want to master MongoDB quickly? PCBooks offers the most comprehensive free MongoDB MCQ bank covering CRUD operations, aggregation pipeline, indexing strategies, and sharding. Perfect for:

📊 MongoDB Core Concepts MCQs

👉 BSON format vs JSON differences
👉 find() vs findOne() performance comparison
👉 Replica sets and sharding architecture
👉 Free mock tests with real interview patterns

⚡ MongoDB Performance Optimization

🎯 Critical concepts covered:
- Indexing strategies (single field, compound, unique)
- Aggregation pipeline optimization ($match early, $project wisely)
- MongoDB Atlas vs self-hosted performance benchmarks
- Change streams for real-time data
🎯 Case-study based questions with explanations
🎯 Downloadable cheat sheets for quick revision

🚀 Start Your Database Journey

SQL MCQs →
DBMS Concepts MCQs →


🏆 Trusted by 55,000+ developers for MongoDB interview prep and NoSQL skill certification!