- 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 - Java Setup
- MongoDB - Java - Create Collection
- MongoDB - Java - Get Collection
- MongoDB - Java - Insert Document
- MongoDB - Java - Retrieve Documents
- MongoDB - Java - Update Document
- MongoDB - Java - Delete Document
- MongoDB - Java - Drop Collection
- MongoDB - Java - List Collections
MongoDB - PHP
- MongoDB - PHP Setup
- MongoDB - PHP - Create Collection
- MongoDB - PHP - Get Collection
- MongoDB - PHP - Insert Document
- MongoDB - PHP - Retrieve Documents
- MongoDB - PHP - Update Document
- MongoDB - PHP - Delete Document
- MongoDB - PHP - Drop Collection
- MongoDB - PHP - List Collections
MongoDB - Advanced
- 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 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 - What kind of database MongoDB is?
Answer : B
Explanation
MongoDB stores data in JSON structure based documents. These documents in turn contains data in form of key value pairs.
Q 2 - mongoimport command is used to:
A - import all the data from one database to another
B - import all the data from one collection to another
C - imports content from an Extended JSON, CSV, or TSV export created by mongoexport
Answer : C
Explanation
The mongoimport tool imports content from an Extended JSON, CSV, or TSV export created by mongoexport, or potentially, another third-party export tool.
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 the posts collection contains an array called ratings which contains ratings given to the post by various users in the following format:
{
_id: 1,
post_text: This is my first post,
ratings: [5, 4, 2, 5],
//other elements of document
}
Which of the following query will return all the documents where the ratings array contains elements that in some combination satisfy the query conditions?
A - db.inventory.find( { ratings: { $elemMatch: { $gt: 3, $lt: 6 } } } )
B - db.inventory.find( { ratings: { ratings: { $gt: 5, $lt: 9 } } } )
C - db.inventory.find( { ratings: { ratings.$: { $gt: 5, $lt: 9 } } } )
D - db.inventory.find( { ratings: { $elemMatch: { $gte: 3, $lte: 6 } } } )
Answer : B
Explanation
This query will check if the array elements match the given condition in some or the other way or combination.
Q 5 - Which are the ONLY ways to project portions of an array?
Answer : D
Explanation
$elemMatch, $slice, and $ are the only way to project portions of an array. For e.g. you cannot use {tags.0:1} for projection.
Answer : B
Explanation
By default GridFS limits chunk size to 255k.
Q 7 - What does the output x of the following MongoDB aggregation query result into:
db.posts.aggregate( [ { $group: { _id: "$author", x: { $sum: $likes } } } ] )A - Average of likes on all the posts of an author, grouped by author
B - Number of posts by an author
C - Sum of likes on all the posts by an author, grouped by author
Answer : C
Explanation
The above query first does a grouping on author field and then calculates the number of likes on all the posts that were grouped together.
Q 8 - Which of the following SQL terminology is same as $match in MongoDB?
Answer : C
Explanation
In MongoDB, we use $match as the aggregation operator corresponding to WHERE and HAVING condition in MongoDB.
Q 9 - Which of the tags in a replica set configuration specify the operations to be read from the node with the least network latency?
Answer : C
Explanation
Operations read from member of the replica set with the least network latency, irrespective of the members type.
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.