
- 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 - What is the maximum size of Index Key Limit and Number of Indexes per collection?
Answer : C
Explanation
The total size of an index entry, which can include structural overhead depending on the BSON type, must be less than 1024 bytes. A single collection can have no more than 64 indexes.
Q 3 - What does the following MongoDB command return?
db.posts.find( { likes : { $gt : 100 }, likes : { $lt : 200 } } );
A - Posts with likes greater than 100 but less than 200
B - Posts with likes greater than or equal to 100 but less than or equal to 200
Answer : C
Explanation
When the mongo shell interprets this query, it will override the first condition $gt and consider only the $lt one. To apply both the less than and greater than condition, you will have to use the $and operator.
Q 4 - What does the following query do when performed on the posts collection?
db.posts.update({_id:1},{$set:{Author:Tom"}})
B - Adds a new field Author in the searched collection if not already present
C - Updates only the Author field of the document with _id as 1
Answer : D
Explanation
$set sets the specific fields in the matched documents or adds them as a new field if not already present.
Q 5 - Which option should be used with findAndModify() command to return the modified document instead of the pre-modification document?
A - findAndModify by default returns the pre-modification document
C - Use the POST version of findAndModify called findAndModifyPost
Answer : B
Explanation
When true, returns the modified document rather than the original. The findAndModify() method ignores the new option for remove operations. The default is false.
Q 6 - Which is the correct order (lowest to highest) in which MongoDB compares the BSON types?
A - Null, Number, String and Object
B - Number, Null, String and Object
Answer : A
Explanation
This is the defined order in which the bson types are compared. There are various other fields as per the BSON specification which can be found here: http://docs.mongodb.org/manual/reference/bson-types/
Answer : B
Explanation
The minimum number of sensible number of voting nodes is 3.
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 - Consider that you have the following two documents in the products collection:
{ "_id" : 1, "prices" : [ 60, 100, 200 ] }
{ "_id" : 2, "prices" : [ 20, 90, 150 ] }
What will the following query result into:db.products.update( { _id: 1, prices: 100 }, { $set: { "prices.$" : 111 } } )
C - Updates 60,100 and 200 to 111
D - Removes the three elements of the prices array and replaces it with only a single element 111
Answer : B
Explanation
The positional $ operator identifies an element in an array to update without explicitly specifying the position of the element in the array. To project, or return, an array element from a read operation, see the $ projection operator.
Q 10 - When should we consider representing a one-to-many relationship in an embedded collection instead of separate collection?
A - When the many is very large
Answer : B
Explanation
If the many is very large, then we should create separate collection, else the document size would go on increasing.