mongodb banner

MongoDB Multiple Choice Questions (MCQs) and Answers

Master MongoDB with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of MongoDB. Begin your placement preparation journey now!

Q1

Q1 What type of database is MongoDB?

A

Relational

B

Document-Oriented

C

Graph

D

Key-Value

Q2

Q2 In MongoDB, what does the term 'collection' refer to?

A

A group of databases

B

A single document

C

A group of documents

D

A type of index

Q3

Q3 What is the outcome of the command db.createCollection("myCollection") in MongoDB?

A

Creates a new document

B

Deletes a collection

C

Creates a new collection

D

Updates a collection

Q4

Q4 Which operating system is NOT supported by MongoDB?

A

Windows

B

Linux

C

macOS

D

iOS

Q5

Q5 What is the default port for MongoDB server?

A

27015

B

28017

C

27017

D

8080

Q6

Q6 Which of the following is required to install MongoDB?

A

Java Runtime Environment

B

Python

C

Node.js

D

None of these

Q7

Q7 In MongoDB, what is the role of the mongod process?

A

Manages the database

B

Runs the shell interface

C

Manages client connections

D

Handles replication

Q8

Q8 What is the primary function of the mongo shell?

A

Data backup

B

Database management and querying

C

User authentication

D

Server monitoring

Q9

Q9 Which file format is used for MongoDB configuration?

A

JSON

B

YAML

C

XML

D

INI

Q10

Q10 Which command is used to start a MongoDB server?

A

mongod start

B

mongo start

C

start mongod

D

run mongod

Q11

Q11 How do you specify an alternate configuration file when starting MongoDB?

A

mongod --config /path/to/config

B

mongod --file /path/to/config

C

mongod -c /path/to/config

D

mongod --use /path/to/config

Q12

Q12 Identify the issue:
mongodb --start

A

Incorrect command format

B

Missing configuration file

C

Incorrect file permissions

D

Outdated MongoDB version

Q13

Q13 MongoDB fails to start with error "Address already in use".
What is the likely cause?

A

Port conflict with another application

B

Insufficient permissions

C

Corrupted installation

D

Outdated MongoDB version

Q14

Q14 What does 'CRUD' stand for in MongoDB?

A

Create, Read, Update, Delete

B

Create, Retrieve, Upload, Delete

C

Connect, Read, Unload, Display

D

Create, Read, Utilize, Deploy

Q15

Q15 Which method is used to insert a single document into a MongoDB collection?

A

db.collection.insertOne()

B

db.collection.insert()

C

db.collection.addOne()

D

db.collection.create()

Q16

Q16 What does the find() method in MongoDB return?

A

A single document

B

An array of documents

C

A cursor

D

A JSON object

Q17

Q17 Which CRUD operation is used to add new data to a MongoDB database?

A

Insert

B

Select

C

Update

D

Delete

Q18

Q18 How does MongoDB treat fields that are not specified in the $set part of an update operation?

A

They are deleted

B

They remain unchanged

C

They are set to null

D

They are marked as undefined

Q19

Q19 What is the purpose of the $unset operator in an update operation in MongoDB?

A

To delete a field from a document

B

To set a field to null

C

To hide a field in the output

D

To create a new field

Q20

Q20 What does the upsert option do in an update operation in MongoDB?

A

Updates an existing document, otherwise does nothing

B

Updates all matching documents

C

Inserts a new document if no match is found

D

Deletes the document if it exists

Q21

Q21 What will the following command do?
db.users.remove({})

A

Remove all documents from the 'users' collection

B

Remove the 'users' collection

C

Remove one random document

D

Do nothing

Q22

Q22 Which command is used to update all documents that meet certain criteria in MongoDB?

A

db.collection.updateMany()

B

db.collection.updateOne()

C

db.collection.update()

D

db.collection.modify()

Q23

Q23 What does this command do?
db.products.find({price: {$gt: 100}})

A

Finds products with a price equal to 100

B

Finds products with a price less than 100

C

Finds products with a price greater than 100

D

Updates the price of products over 100

Q24

Q24 Which MongoDB command is used to add a new field to an existing document?

A

db.collection.update({}, {$set: {newField: value}})

B

db.collection.add({}, {newField: value})

C

db.collection.newField({newField: value})

D

db.collection.addField({newField: value})

Q25

Q25 Identify the issue:
db.users.find({age: "25"})

A

Incorrect collection name

B

Incorrect field name

C

Type mismatch in query value

D

Missing query operator

Q26

Q26 What's wrong with this update command?
db.users.update({name: "John"}, {age: 30})

A

It replaces the entire document

B

It's missing the $set operator

C

It updates all users named John

D

There's no issue

Q27

Q27 Spot the error in this command:
db.collection.deleteOne({ _id: 123 })

A

Incorrect method name

B

Incorrect field value

C

Missing quotation marks around the _id value

D

No error

Q28

Q28 Why might db.collection.insertOne({name: "Alice", age: null}) not add a new document?

A

'age' field cannot be null

B

'name' field is duplicated

C

Collection does not exist

D

Missing required fields

Q29

Q29 In MongoDB, what is a 'schema'?

A

A predefined structure for data

B

A query language for the database

C

A tool for data replication

D

A security feature

Q30

Q30 Which of the following best describes MongoDB's approach to schemas?

A

Rigid and predefined

B

Flexible and dynamic

C

Fixed and unchangeable

D

None, as MongoDB does not use schemas

...
ad verticalad vertical
ad