- 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 - In a collection that contains 100 post documents, what does the following command do?
db.posts.find().skip(5).limit(5)
A - Skip and limit nullify each other. Hence returning the first five documents.
B - Skips the first five documents and returns the sixth document five times
C - Skips the first five documents and returns the next five
D - Limits the first five documents and then return them in reverse order
Answer : C
Explanation
The skip and limit functions are applies linearly and hence it will first skip documents 1-5, and then return documents 6-10.
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 operations on a single document will operate atomically?
Answer : C
Explanation
Both the update and $push operators will operate in an atomic way.
Q 4 - Consider that you are using { upsert : true } option in your update command. Which of the following parameters will be used to determine if any new documents were inserted:
Answer : D
Explanation
The nUpserted shows the number of documents that were added during the update operation.
Q 5 - Which type of indexes does MongoDB support?
Answer : D
Explanation
MongoDB supports all of the above mentioned indexes.
Q 6 - For capped collection, cursors which do not automatically close and remain open after the client exhausts the results are called:
Answer : B
Explanation
By default, MongoDB will automatically close a cursor when the client has exhausted all results in the cursor. However, for capped collections you may use a Tailable Cursor that remains open after the client exhausts the results in the initial cursor.
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 as well as acknowledged by at least 3 nodes. What should be the value of w?
Answer : C
Explanation
The value of w determines the writes are committed and acknowledged by some minimum number of nodes which in this case is 3.
Q 8 - Which of the following command is used to get all the indexes on a collection?
A - db.collection.getIndexes()
B - db.collection.showIndexes()
Answer : A
Explanation
db.collection.getIndexes() is the correct choice.
Q 9 - The oplog (operations log) is a special capped collection that keeps a rolling record of all operations that modify the data stored in your databases. All the replica set members contain a copy of the oplog in the following collection:
Answer : B
Explanation
All replica set members contain a copy of the oplog, in the local.oplog.rs collection, which allows them to maintain the current state of the database.
Q 10 - Which of the following operator can be used to control the number of items of an array that a query returns?
D - MongoDB does not support partial retrieval of items from an array
Answer : C
Explanation
The $slice operator controls the number of items of an array that a query returns.