Learn MongoDB MCQs
Prepare MongoDB MCQs (Multiple choice Questions) for exam and job interviews.
What does the command `db.collection_name.find({field: {$exists: false}})` do?
1) Finds documents where field does not exist
2) Finds all documents
3) Finds documents where field is null
4) Finds documents where field exists
Answer : Option 1
Which operator is used to perform a bitwise AND operation?
1) $bit
2) $and
3) $or
4) $not
Answer : Option 1
What command is used to create a backup of the MongoDB database?
1) mongodump
2) backup db_name
3) db.backup()
4) dumpDatabase()
Answer : Option 1
Which command is used to restore a MongoDB database from a backup?
1) mongorestore
2) db.restore()
3) restoreDatabase()
4) db.loadBackup()
Answer : Option 1
What is the purpose of the `$addFields` stage in aggregation?
1) Adds new fields to documents
2) Removes fields
3) Updates fields
4) Sorts documents
Answer : Option 1
Which method is used to retrieve a document by a specific field?
1) db.collection_name.findOne({field: value})
2) db.collection_name.get({field: value})
3) db.collection_name.retrieve({field: value})
4) db.collection_name.find({field: value})
Answer : Option 1
What is the command to find documents in a collection that match multiple criteria?
1) db.collection_name.find({field1: value1, field2: value2})
2) db.collection_name.find({field1: value1}) && {field2: value2}
3) db.collection_name.find({$and: [{field1: value1}, {field2: value2}]})
4) db.collection_name.findAll({field1: value1, field2: value2})
Answer : Option 1
Which command is used to enable sharding on a database?
1) sh.enableSharding("database_name")
2) db.shard.enable("database_name")
3) enableSharding("database_name")
4) shardDatabase("database_name")
Answer : Option 1
What is the maximum number of fields allowed in a single MongoDB document?
1) 16 MB
2) 100
3) 1000
4) Unlimited
Answer : Option 1
Which command is used to insert multiple documents at once?
1) db.collection_name.insertMany()
2) db.collection_name.insertMultiple()
3) db.collection_name.insertAll()
4) db.collection_name.addMany()
Answer : Option 1