Learn MongoDB MCQs
Prepare MongoDB MCQs (Multiple choice Questions) for exam and job interviews.
What does the `find()` method return when no documents match the query?
1) An empty cursor
2) An empty document
3) Null
4) An error
Answer : Option 1
Which of the following is a NoSQL database?
1) MySQL
2) Oracle
3) MongoDB
4) PostgreSQL
Answer : Option 3
What is the default port for MongoDB?
1) 27017
2) 5432
3) 3306
4) 1521
Answer : Option 1
What command is used to create an index on a single field?
1) db.collection_name.createIndex({field: 1})
2) db.createIndex()
3) db.collection_name.index()
4) db.createSingleIndex()
Answer : Option 1
Which operator is used to filter documents with an array containing specific values?
1) $elemMatch
2) $in
3) $all
4) $exists
Answer : Option 1
What is the maximum size of a document in MongoDB?
1) 16 MB
2) 2 MB
3) 1 GB
4) 64 MB
Answer : Option 1
What command is used to find all documents in a collection?
1) db.collection_name.find()
2) db.collection_name.getAll()
3) db.collection_name.findAll()
4) db.collection_name.retrieve()
Answer : Option 1
Which of the following is NOT a MongoDB data type?
1) String
2) Date
3) Boolean
4) Currency
Answer : Option 4
What does the command `db.collection_name.updateMany({field: value}, {$set: {field2: newValue}})` do?
1) Updates all matching documents
2) Updates the first matching document
3) Deletes matching documents
4) Inserts new documents
Answer : Option 1
Which operator is used to perform a logical AND operation?
1) $and
2) $or
3) $nor
4) $not
Answer : Option 1