Database - MongoDB MCQ Questions and Answers

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

« First 4 5 6 7 Last »
« Previous Page Next Page »

81. Which command creates a MongoDB Atlas Search index?

  • a) db.collection.createSearchIndex({...})
  • b) db.createAtlasIndex()
  • c) db.collection.makeSearchIndex()
  • d) db.searchIndex()
Answer: A - Atlas Search indexes are created with createSearchIndex() and support full-text search features.

82. What is the purpose of the $search aggregation stage?

  • a) Performs full-text search using Atlas Search
  • b) Searches across collections
  • c) Implements regex search
  • d) Validates search queries
Answer: A - $search leverages Atlas Search indexes for advanced text search capabilities.

83. Which operator performs graph traversal in MongoDB?

  • a) $graphLookup
  • b) $traverse
  • c) $connect
  • d) $path
Answer: A - $graphLookup performs recursive searches on document relationships.

84. What does the $collStats aggregation stage return?

  • a) Collection storage and index statistics
  • b) Collation settings
  • c) Document count only
  • d) Shard distribution
Answer: A - $collStats provides storage metrics, index details, and sharding information.

85. Which method safely shuts down a mongod instance?

  • a) db.shutdownServer()
  • b) db.stop()
  • c) mongod --shutdown
  • d) db.exit()
Answer: A - db.shutdownServer() performs a clean shutdown when connected to admin database.

86. What is the purpose of the $planCacheStats operator?

  • a) Displays query plan cache information
  • b) Optimizes cache usage
  • c) Clears stale plans
  • d) Creates cached indexes
Answer: A - $planCacheStats reveals how query shapes are cached for optimization.

87. Which command creates a MongoDB view?

  • a) db.createView("viewName", "source", [pipeline])
  • b) db.view.create()
  • c) db.makeView()
  • d) db.collection.view()
Answer: A - Views are created with an aggregation pipeline and behave like read-only collections.

88. What does the $indexStats aggregation stage return?

  • a) Index usage statistics
  • b) List of indexes
  • c) Index creation commands
  • d) Index storage size
Answer: A - $indexStats shows how often each index is used for queries.

89. Which operator implements Redact in aggregation?

  • a) $redact
  • b) $filter
  • c) $mask
  • d) $secure
Answer: A - $redact controls document field visibility based on conditional logic.

90. What is the purpose of the $sample stage?

  • a) Randomly selects documents
  • b) Creates data samples
  • c) Generates test data
  • d) Divides collections
Answer: A - { $sample: { size: 10 } } returns a random document subset.

91. Which method returns MongoDB server status?

  • a) db.serverStatus()
  • b) db.status()
  • c) mongod --status
  • d) db.health()
Answer: A - serverStatus() provides instance metrics like connections, memory, and operations.

92. What does the $mergeObjects operator do?

  • a) Combines multiple documents
  • b) Merges collections
  • c) Joins sharded data
  • d) Overwrites duplicate fields
Answer: A - { $mergeObjects: [doc1, doc2] } creates a union of fields (last document wins conflicts).

93. Which command lists all MongoDB users?

  • a) db.getUsers()
  • b) show users
  • c) db.users()
  • d) db.listUsers()
Answer: D - db.listUsers() displays all users for the current database.

94. What is the purpose of the $switch operator?

  • a) Conditional branching in aggregations
  • b) Changes database connections
  • c) Swaps collection names
  • d) Toggles indexes
Answer: A - $switch works like a switch/case statement in aggregation pipelines.

95. Which operator validates BSON types?

  • a) $type
  • b) $bson
  • c) $validate
  • d) $checkType
Answer: A - { field: { $type: "string" } } matches documents with specific BSON types.

96. What does the $dateFromString operator do?

  • a) Converts string to date
  • b) Formats date as string
  • c) Validates date strings
  • d) Parses timestamps
Answer: A - { $dateFromString: { dateString: "$dateStr" } } parses strings into Date objects.

97. Which method exports MongoDB data to JSON?

  • a) mongoexport
  • b) mongodump
  • c) db.export()
  • d) saveAsJSON()
Answer: A - The mongoexport CLI tool exports collections to JSON or CSV.

98. What is the purpose of the $concatArrays operator?

  • a) Merges multiple arrays
  • b) Concatenates strings
  • c) Combines collections
  • d) Joins sharded chunks
Answer: A - { $concatArrays: [array1, array2] } creates a new combined array.

99. Which command enables MongoDB auditing?

  • a) mongod --auditDestination
  • b) db.enableAuditing()
  • c) db.audit()
  • d) audit.enable()
Answer: A - Auditing requires server configuration with --auditDestination flag (file/syslog/console).

100. What does the $isoWeek operator return?

  • a) ISO week number of the year (1-53)
  • b) ISO timestamp
  • c) ISO country code
  • d) ISO formatted date
Answer: A - { $isoWeek: "$date" } extracts the ISO 8601 week number from a date.
« First 4 5 6 7 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!