MongoDB Quiz - MCQ - Multiple Choice Questions

MongoDB is a popular open-source, NoSQL database that stores data in a flexible, JSON-like format called BSON. Unlike relational databases, which organize data in tables, MongoDB uses collections to hold documents, making it highly adaptable to diverse data structures.

As you embark on your journey to master MongoDB, this quiz will help test your knowledge of its fundamental concepts.

Note that each question is followed by the correct answer and an explanation to help reinforce your knowledge.

1. Which of the following best describes MongoDB?

A. Relational database
B. Spreadsheet program
C. Document-based NoSQL database
D. Graph database

2. In MongoDB, a record is equivalent to a:

A. Row
B. Table
C. Document
D. Database

3. Which of the following is the default port for MongoDB?

A. 27017
B. 8080
C. 3306
D. 5432

4. Which MongoDB command is used to display the database you are currently using?

A. show currentDatabase
B. show db
C. use db
D. db

5. To create or switch to a database in MongoDB, which command would you use?

A. createDatabase(name)
B. switchDatabase(name)
C. use <database_name>
D. db.<database_name>

6. Which of the following commands will show you all the collections in your current database?

A. show collections
B. list collections
C. display collections
D. db.collections()

7. How do you insert a new document into a collection in MongoDB?

A. db.<collection_name>.insert()
B. db.<collection_name>.newDocument()
C. db.<collection_name>.add()
D. db.<collection_name>.append()

8. Which of the following commands deletes a MongoDB database?

A. db.dropDatabase()
B. removeDatabase()
C. deleteDatabase()
D. destroyDatabase()

9. Which MongoDB method can be used to remove one or more documents from a collection?

A. db.<collection_name>.delete()
B. db.<collection_name>.remove()
C. db.<collection_name>.discard()
D. db.<collection_name>.drop()

10. What is the BSON in MongoDB?

A. A database engine
B. A query language
C. A backup tool
D. Binary representation of JSON

11. Which MongoDB command returns statistics about the database?

A. db.stats()
B. db.info()
C. db.data()
D. db.details()

12. What format does MongoDB use for its queries?

A. SQL
B. XML
C. BSON
D. XQuery

13. To update a document in a collection, which method is appropriate?

A. db.<collection_name>.modify()
B. db.<collection_name>.edit()
C. db.<collection_name>.revise()
D. db.<collection_name>.update()

14. Which of the following operations provides a sorted list of the documents in a collection?

A. db.<collection_name>.sort()
B. db.<collection_name>.arrange()
C. db.<collection_name>.listSorted()
D. db.<collection_name>.orderBy()

15. How can you backup your MongoDB database?

A. mongodump
B. mongobackup
C. mongosave
D. mongoarchive

16. Which tool can be used to import content from a BSON file into a MongoDB database?

A. mongoimport
B. mongorestore
C. mongoload
D. mongofetch

17. Which of the following commands lists all available MongoDB databases?

A. show dbs
B. list dbs
C. show databases
D. db.list()

18. Which MongoDB function is used to limit the number of results returned?

A. db.<collection_name>.count()
B. db.<collection_name>.skip()
C. db.<collection_name>.limit()
D. db.<collection_name>.restrict()

19. In which language is MongoDB written?

A. Python
B. Java
C. C++
D. Go

20. If you wish to retrieve only the specified fields of a document, which method would you use?

A. project()
B. show()
C. select()
D. find()

21. Which of the following ensures atomic transactions in MongoDB?

A. WriteConcern
B. Sharding
C. Indexing
D. Replication

22. Which of the following is NOT a valid logical operator in MongoDB?

A. $and
B. $or
C. $nor
D. $between

23. If you want to join collections in MongoDB, which operator would you use?

A. $join
B. $link
C. $lookup
D. $merge

24. What type of index in MongoDB allows you to search text fields?

A. Text index
B. Compound index
C. Unique index
D. Sparse index

25. Which MongoDB command provides execution statistics about query performance?

A. db.<collection_name>.stats()
B. db.<collection_name>.explain()
C. db.<collection_name>.details()
D. db.<collection_name>.analyze()

26. How do you create a unique index on a field in MongoDB?

A. { uniqueKey: 1 }
B. { index: "unique" }
C. { type: "unique" }
D. { unique: true }

27. Which MongoDB shell method is used to rename a collection?

A. db.<collection_name>.rename()
B. db.<collection_name>.renameCollection()
C. db.<collection_name>.changeName()
D. db.<collection_name>.alter()

28. What does the mongos command do?

A. Starts the MongoDB server.
B. Starts a shard server.
C. Starts the MongoDB routing service.
D. Dumps the MongoDB database.

29. In which format does MongoDB store its data?

A. XML
B. JSON
C. CSV
D. BSON

30. Which command is used to terminate a long-running operation in MongoDB?

A. db.killOp()
B. db.stopOp()
C. db.terminate()
D. db.endOp()

Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare