
- 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
- 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 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 is the default mode in which the explain() command runs?
Answer : A
Explanation
Default mode is "queryPlanner".
Q 3 - Which of the following command can be used to check the size of a collection named posts?
Answer : A
Explanation
To view the statistics for a collection, including the data size, use the db.collection.stats() method from the mongo shell.
Q 4 - Consider that our posts collection contains an array field called tags that contains tags that the user enters.
{ _id: 1, tags: [tutorial, fun, learning], post_text: This is my first post, //other elements of document }
What does the following command return:
db.posts.find( { 'tags.0': tutorial } )
A - All the posts whose tags array contains tutorial
B - All the posts which contains only one tag element in the tag array
C - All the posts having the first element of the tags array as tutorial
D - All the posts which contains 0 or more tags named tutorial
Answer : C
Explanation
tags.0 means that the 0th element of the tag. This is the specific matching of an element in array.
Q 5 - If the value of totalKeysExamined is 30000 and the value of totalDocsExamined is 0, which of the following option is correct?
A - The query used an index to fetch the results
B - The query returned 30000 documents after scanning the documents
Answer : A
Explanation
When an index covers a query, the explain result has an IXSCAN stage that is not a descendant of a FETCH stage, and in the executionStats, the totalDocsExamined is 0.
Q 6 - Update If Correct is an approach for which of the following concepts in MongoDB:
Answer : A
Explanation
The Update if Current pattern is an approach to concurrency control when multiple applications have access to the data.
Q 7 - What does the following aggregate query perform?
db.posts.aggregate( [ { $match : { likes : { $gt : 100, $lte : 200 } } }, { $group: { _id: null, count: { $sum: 1 } } } ] );
A - Calculates the number of posts with likes between 100 and 200
B - Groups the posts by number of likes (101, 102, 103.) by adding 1 every time
C - Fetches the posts with likes between 100 and 200 and sets their _id as null
Answer : A
Explanation
The above query basically matches all the documents having likes between 100 and 200. After that, it just specifies that aggregation is not to be done with any specific column (_id:null) and increments the count every time. Thus calculating the total such posts.
Q 8 - Given a collection posts as shown below having a document array comments, which of the following command will create an index on the comment author descending?
{ _id:1, post_text:This is a sample post, author:Tom, comments:[ { author:Joe, comment_text:This is comment 1 }, { author:Leo, comment_text:This is comment 2 } ] }
A - db.posts.createIndex({comments.$.author":-1});
B - db.posts.createIndex({comments.author":-1});
Answer : B
Explanation
We can access the document fields within an array using dot notation. And for indicating the index sorting, we just have to mention 1 or -1.
Q 9 - We can insert multiple documents in bulk using which of the following operations:
Answer : A
Explanation
The initializeUnorderedBulkOp operation returns an unordered operations builder which maintains a list of operations to perform. Unordered operations means that MongoDB can execute in parallel as well as in nondeterministic order.
Q 10 - Which command can be used to rebuild the indexes on a collection in MongoDB?
A - db.collection.createIndex({reIndex:1})
Answer : C
Explanation
If you need to rebuild indexes for a collection you can use the db.collection.reIndex() method to rebuild all indexes on a collection in a single operation. This operation drops all indexes, including the _id index, and then rebuilds all indexes.