
- 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 correct about MongoDB?
A - MongoDB uses JSON format to represent documents
B - MongoDB supports collection joins
Answer : D
Explanation
MongoDB provides specific supports for functionalities related to 2d and 3d geospatial problems.
Q 2 - Which of the following commands finds all the documents in the posts collection with post timestamp field as null?
A - db.posts.find( { post_timestamp : { $type: 10 } } )
B - db.posts.find( { post_timestamp: { $type: null } } )
C - db.posts.find( { post_timestamp: { $fieldtype: 10 } } )
D - db.posts.find( { post_timestamp: { $fieldtype: null } } )
Answer : A
Explanation
$type is used for all the operations involving checking the type of a field in MongoDB. 10 represents the BSON value for null.
Q 3 - In our posts collection, which command can be used to find all the posts whose author names begin lie between “A” and “C” in dictionary order?
A - db.posts.find( { post_author : { $gte : "A" , $lte : "C" } } );
B - db.posts.find( { post_author : { $gte : "C" , $lte : "A" } } );
C - db.posts.find( { post_author : { $gt : "A" , $lt : "C" } } );
Answer : A
Explanation
The $gt, $lt and related operators can be applied for string manipulations too. They work in the same manner as they would work on numeric values.
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 - You can implement a multi-document transaction in MongoDB using which of the following concept?
Answer : B
Explanation
Operations on a single document are always atomic with MongoDB databases; however, operations that involve multiple documents, which are often referred to as “multi-document transactions”, are not atomic.
Q 6 - What is the equivalent command in MongoDB for the following SQL query?
SELECT * FROM posts WHERE author like "%john%"
A - db.posts.find( { author: /john/ } )
B - db.posts.find( { author: {$like: /john/} } )
Answer : A
Explanation
db.posts.find( { author: /john/ } )
Q 7 - Consider that you have a collection called population which has fields state and city. Which of the following query will calculate the population grouped by state and city?
Answer : A
Explanation
You have to give state and city as the key to group by and then calculate the sum of the population in each city.
Q 8 - What will be the equivalent MongoDB command for the following SQL command:
SELECT author, count(*) FROM posts GROUP BY author HAVING count(*) > 1Answer : B
Explanation
The query in option 2, first of all groups the records by _id as author. This will group all the posts with same author and calculate the sum. Now that we have the sum with us, we are filtering on this count being greater than 1 in the next $match statement.
Q 9 - In a sharded replica set environment, w defines the level and kind of write concern. Which of the following values of w specifies to return success only after a majority of voting members have acknowledged?
Answer : B
Explanation
For replica sets, if you specify the special majority value to w option, write operations will only return successfully after a majority of the voting members of the replica set have acknowledged the write operation.
Q 10 - What does the following $slice query return using the following command?
db.posts.find( {}, { comments: { $slice: [ -10, 5 ] } } )
A - Returns 5 comments, beginning with the last 10 items
B - Returns 10 comments, beginning with the first
Answer : A
Explanation
The $slice operation selects the document collection identified by a field named field that holds value and returns the number of elements specified by the value of count from the array stored in the array field.