
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MongoDB Online Quiz
Following quiz provides Multiple Choice Questions (MCQs) related to MongoDB Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Q 1 - Which of the following is a valid MongoDB JSON document:
B
{
"user_id"=1,
"user_name"="Joe Sanders",
"occupation"=["engineer","writer"]
}
C
{
"user_id":1;
"user_name":"Joe Sanders";
"occupation":["engineer","writer"]
}
Answer : A
Explanation
A blank document is valid in MongoDB. However, rest of the three documents have some or the other problem. Option b has “=”, Option c has “;” and Option d has an incorrect array format. It should be a sub-document instead.
Answer : A
Explanation
In the default configuration, MongoDB writes data to the main data files on disk every 60 seconds.
Q 3 - Which of the following commands will return all the posts with number of likes greater than 100 and less than 200, both inclusive?
A - db.posts.find({ likes : { $gt : 100, $lt : 200 } } );
B - db.posts.find({ likes : { $gte : 100, $lt : 200 } } );
C - db.posts.find({ likes : { $gt : 100 , $lte : 200 } } );
D - db.posts.find({ likes : { $gte : 100 , $lte : 200 } } );
Answer : D
Explanation
Since 100 and 200 are both inclusive, we need $gte (greater than and equal) and $lte (less than and equal).
Q 4 - Which option should be used to update all the documents with the specified condition in the MongoDB query?
A - updateAll instead of update
B - specify {multi : true} as the third parameter of update command
C - specify {all: true} as the third parameter of update command
D - specify {updateAll: true} as the third parameter of update command
Answer : B
Explanation
{multi:true} should be used for this purpose. By default, MongoDB will update only the first document.
Q 5 - Which of the following methods can be used on a cursor object?
Answer : D
Explanation
All of the above methods can be used on a cursor object.
Q 6 - Which of the following is not a system collection in MongoDB?
Answer : D
Explanation
There is no system collection to store database preferences.
Q 7 - What does the output x of the following MongoDB aggregation query result into:
db.posts.aggregate( [ { $group: { _id: "$author", x: { $sum: “$likes” } } } ] )A - Average of likes on all the posts of an author, grouped by author
B - Number of posts by an author
C - Sum of likes on all the posts by an author, grouped by author
Answer : C
Explanation
The above query first does a grouping on author field and then calculates the number of likes on all the posts that were grouped together.
Q 8 - Which of the following aggregation commands in MongoDB does not support sharded collections?
Answer : C
Explanation
The group command in MongoDB groups documents in a collection by the specified key and performs simple aggregation functions, such as computing counts and sums. It is the most basic one and does not support such sharding concepts.s
Q 9 - Which of the following operators can reverse the effects of a double unwind operation?
Answer : A
Explanation
An unwind operation unwinds on an array field and creates separate documents. If you unwind it again same thing happens again. So if you had one document which had two arrays, the first array had 2 values and second array has 3 values. Unwinding this document two times will give 6 document. Now to combine them back, you can use the $push operator.
Q 10 - If you have created a compound index on (A,B, C) which of the following access pattern will not be able to utilize the index?
Answer : C
Explanation
Since the index itself starts from A, it cannot be utilized it the input query is starting with B.