Learn MongoDB MCQs

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

What command is used to insert a document into a collection in MongoDB?

1) INSERT INTO collection_name

2) db.collection_name.insert()

3) INSERT collection_name

4) db.collection_name.add()

Answer : Option 2

Which method is used to find a document in a MongoDB collection?

1) db.collection_name.search()

2) db.collection_name.findOne()

3) db.collection_name.get()

4) db.collection_name.find()

Answer : Option 2

What is the default port for MongoDB?

1) 27017

2) 8080

3) 5432

4) 3306

Answer : Option 1

Which of the following is a valid MongoDB query operator?

1) $gt

2) >

3) >=

4) ==

Answer : Option 1

What does the acronym BSON stand for?

1) Binary JSON

2) Binary Structured Object Notation

3) Basic JSON

4) Binary Stored Object Notation

Answer : Option 1

How do you update a document in MongoDB?

1) db.collection_name.update()

2) db.collection_name.modify()

3) db.collection_name.change()

4) db.collection_name.edit()

Answer : Option 1

Which of the following is NOT a MongoDB data type?

1) ObjectId

2) String

3) ArrayList

4) Date

Answer : Option 3

What command is used to create a new database in MongoDB?

1) CREATE DATABASE

2) db.createDatabase()

3) USE database_name

4) db.database_name.create()

Answer : Option 3

How do you delete a document in MongoDB?

1) db.collection_name.deleteOne()

2) db.collection_name.remove()

3) db.collection_name.delete()

4) db.collection_name.drop()

Answer : Option 1

Which function is used to aggregate data in MongoDB?

1) db.collection_name.group()

2) db.collection_name.aggregate()

3) db.collection_name.sum()

4) db.collection_name.total()

Answer : Option 2