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 »

181. Which command configures MongoDB Atlas App Services?

  • a) Atlas UI/API only
  • b) db.createAppService()
  • c) mongod --appServices
  • d) db.appServices.setup()
Answer: A - App Services (formerly Realm) are configured through Atlas interface for serverless apps.

182. What is the purpose of the $millisecond operator?

  • a) Returns millisecond portion of date (0-999)
  • b) Converts to milliseconds
  • c) Measures execution time
  • d) Validates timestamp precision
Answer: A - { $millisecond: "$date" } extracts the millisecond component.

183. Which method enables MongoDB's LDAP authentication?

  • a) mongod --auth --setParameter authenticationMechanisms=PLAIN,LDAP
  • b) db.enableLDAP()
  • c) db.auth.ldap()
  • d) Requires configuration file
Answer: D - LDAP requires security.ldap settings in mongod.conf and proper startup flags.

184. What does the $second operator return?

  • a) Second portion of date (0-59)
  • b) Unix timestamp
  • c) Sequence number
  • d) Validation second
Answer: A - { $second: "$date" } extracts the second component (including leap seconds).

185. Which operator performs case-insensitive string comparison?

  • a) $strcasecmp
  • b) $cmp
  • c) $eq
  • d) $stringEqual
Answer: A - { $strcasecmp: ["text", "TEXT"] } returns 0 (equal).

186. What is the purpose of the $limit stage?

  • a) Restricts document count
  • b) Sets memory bounds
  • c) Controls resource usage
  • d) Filters by size
Answer: A - { $limit: 10 } passes only the first 10 documents downstream.

187. Which command lists all MongoDB's current sessions?

  • a) db.adminCommand({ listSessions: 1 })
  • b) db.sessions()
  • c) show sessions
  • d) db.serverStatus().sessions
Answer: A - Requires admin database access to list all active sessions.

188. What does the $toDouble operator do?

  • a) Converts value to double
  • b) Validates decimals
  • c) Rounds numbers
  • d) Casts to float
Answer: A - { $toDouble: "3.14" } returns 3.14 as 64-bit floating point.

189. Which method returns MongoDB's operation execution stats?

  • a) db.serverStatus().opExecutionStats
  • b) db.ops()
  • c) mongod --ops
  • d) db.currentOp().stats
Answer: A - Operation execution metrics are nested in serverStatus() output.

190. What is the purpose of the $dateToString operator with format?

  • a) Formats date as custom string
  • b) Converts strings to dates
  • c) Validates date formats
  • d) Serializes timestamps
Answer: A - { $dateToString: { format: "%Y-%m-%d", date: "$date" } } produces "2023-06-15".

191. Which operator checks if all array elements match a condition?

  • a) $allElementsTrue
  • b) $all
  • c) $filter
  • d) $map
Answer: A - { $allElementsTrue: { $map: { input: "$array", in: condition } } }.

192. What does the $toLong operator do?

  • a) Converts value to 64-bit integer
  • b) Truncates decimals
  • c) Validates long numbers
  • d) Extends precision
Answer: A - { $toLong: "1234567890" } returns a 64-bit integer.

193. Which command lists all Atlas Triggers?

  • a) Atlas UI/API only
  • b) db.getTriggers()
  • c) show triggers
  • d) db.triggers.list()
Answer: A - Triggers are managed through Atlas interface, not shell commands.

194. What is the purpose of the $toDecimal operator?

  • a) Converts value to 128-bit decimal
  • b) Formats decimals
  • c) Validates precision
  • d) Rounds numbers
Answer: A - { $toDecimal: "123.456" } returns high-precision decimal (MongoDB 4.4+).

195. Which operator checks if value is a boolean?

  • a) $isBoolean
  • b) $type: "bool"
  • c) $boolean
  • d) $checkType
Answer: B - Use { $type: ["$field", "bool"] } to check boolean type.

196. What does the $minute operator return?

  • a) Minute portion of date (0-59)
  • b) Time interval
  • c) Duration in minutes
  • d) Validation minute
Answer: A - { $minute: "$date" } extracts the minute component.

197. Which method returns MongoDB's WiredTiger cache stats?

  • a) db.serverStatus().wiredTiger.cache
  • b) db.cacheStats()
  • c) mongod --cache
  • d) db.wiredTigerInfo()
Answer: A - Cache utilization metrics are in serverStatus()'s WiredTiger section.

198. What is the purpose of the $toBool operator?

  • a) Converts value to boolean
  • b) Validates truthy values
  • c) Casts to true/false
  • d) Filters booleans
Answer: A - { $toBool: 1 } returns true, { $toBool: 0 } returns false.

199. Which operator checks if value is a date?

  • a) $isDate
  • b) $type: "date"
  • c) $date
  • d) $checkDate
Answer: B - Use { $type: ["$field", "date"] } to verify date type.

200. What does the $year operator return?

  • a) Year portion of date
  • b) Fiscal year
  • c) Current year
  • d) Validation year
Answer: A - { $year: "$date" } extracts the 4-digit year (e.g., 2023).
« 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!