Learn MongoDB MCQs

Prepare MongoDB MCQs (Multiple choice Questions) for exam and job interviews.

What is the purpose of the `MongoDB Compass` application?

1) Graphical user interface for MongoDB

2) Command line tool for MongoDB

3) Data analysis tool

4) Backup tool

Answer : Option 1

What is a `Replica Set` in MongoDB?

1) A group of MongoDB servers that maintain the same data set

2) A single MongoDB server

3) A collection of indexes

4) A backup system

Answer : Option 1

Which operator is used to perform an OR condition in MongoDB?

1) $or

2) $and

3) $not

4) $exists

Answer : Option 1

What is the purpose of the `$limit` stage in MongoDB aggregation?

1) Limits the number of documents passed to the next stage

2) Filters documents

3) Groups documents

4) Sorts documents

Answer : Option 1

What does the command `db.collection_name.createIndex({field: 1})` do?

1) Creates an ascending index on the field

2) Creates a descending index on the field

3) Drops the index

4) Renames the index

Answer : Option 1

Which method is used to find all documents in a collection?

1) db.collection_name.find()

2) db.collection_name.getAll()

3) db.collection_name.fetch()

4) db.collection_name.findAll()

Answer : Option 1

What is the primary purpose of `MongoDB Atlas`?

1) Cloud-based MongoDB service

2) Local database management

3) Data analysis tool

4) Backup service

Answer : Option 1

Which operator is used to filter documents with specific values in an array field?

1) $elemMatch

2) $all

3) $in

4) $any

Answer : Option 1

What is the command to connect to a MongoDB database from the shell?

1) mongo database_name

2) connect database_name

3) db.connect(database_name)

4) db.database_name.connect()

Answer : Option 1

Which command is used to display all databases in MongoDB?

1) show dbs

2) db.show()

3) list databases

4) db.getAll()

Answer : Option 1