- 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
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 incorrect statement about find and findOne operations in MongoDB?
A - find() returns all the documents in a collection while findOne() retrieves only the first one.
B - find() and findOne() returns cursors to the collection documents
C - findOne() returns the actual first document retrieved from a collection
Answer : B
Explanation
Both findOne() and find() queries are very much different. The find() method returns the cursor while the findOne() returns the actual document. Hence Option b is incorrect and rest of them are correct.
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 - 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 - 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 - What does the totalKeysExamined field returned by the explain method indicate?
A - Number of documents that match the query condition
B - Number of index entries scanned
C - Number of documents scanned
D - Details the completed execution of the winning plan as a tree of stages
Answer : B
Explanation
explain.executionStats.totalKeysExamined indicates the number of index entries scanned.
Q 6 - Aggregation Pipelines have a limit of:
A - 2 MB document and 100 MB RAM
B - 16 MB document and 100 MB RAM
Answer : B
Explanation
Pipeline stages have a limit of 100 megabytes of RAM. If a stage exceeds this limit, MongoDB will produce an error. If the aggregate command returns a single document that contains the complete result set, the command will produce an error if the result set exceeds the BSON Document Size limit, which is currently 16 megabytes.
Q 7 - In a sharded replica set environment, the w Option provides ability for write concern and j Option provides ability for the data to be written on disk journal. Consider that we have a seven member replica set and we want to assure that the writes are committed to journal. What should be the value of j?
Answer : B
Explanation
To enable the disk journaling commits, j value should always be set to 1.
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 - 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 - The ________ operator limits the contents of an array field from the query results to contain only the first element matching the query condition.
Answer : B
Explanation
The $elemMatch operator limits the contents of an array field from the query results to contain only the first element matching the $elemMatch condition.
To Continue Learning Please Login
Login with Google