- 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 - The MongoDB explain() method does not support which of the following verbosity mode:
Answer : D
Explanation
The possible modes of explain() are: "queryPlanner", "executionStats", and "allPlansExecution".
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 is supported by MongoDB?
B - Relationships between Collections (Primary Key Foreign Key)
Answer : C
Explanation
MongoDB does not support things like ACID Transactions or atomicity across collections or relationships like SQL.
Q 4 - Which option should be used to update all the documents with the specified condition in the MongoDB query?
A - updateAll instead of update
B - specify {multi : true} as the third parameter of update command
C - specify {all: true} as the third parameter of update command
D - specify {updateAll: true} as the third parameter of update command
Answer : B
Explanation
{multi:true} should be used for this purpose. By default, MongoDB will update only the first document.
Q 5 - Which of the following methods can be used on a cursor object?
Answer : D
Explanation
All of the above methods can be used on a cursor object.
Q 6 - What is the equivalent command in MongoDB for the following SQL query?
SELECT * FROM posts WHERE author like "%john%"
A - db.posts.find( { author: /john/ } )
B - db.posts.find( { author: {$like: /john/} } )
Answer : A
Explanation
db.posts.find( { author: /john/ } )
Q 7 - In a sharded replicas set environment with multiple mongos servers, which of the following would decide the mongos failover?
Answer : C
Explanation
Since the mongos are itself failing in this case, this logic has to be built on the drivers side.
Q 8 - In a replica set, a ________ number of members ensures that the replica set is always able to select a primary.
Answer : A
Explanation
An odd number of members ensures that the replica set is always able to elect a primary. If you have an even number of members, add an arbiter to get an odd number.
Q 9 - Which of the following is the correct syntax for starting a new mongod process and specifying its replica set name as rs0:
D - First execute this: mongod --replSet. And then execute this: rs.add()
Answer : A
Explanation
Replica set can be set/stated using the replSet command and specifying the replica name with it.
Q 10 - Consider the following document from the products collection:
{
_id: 1,
product_code: "345678",
variations: [
{ size: "L", price: 1000 },
{ size: "M", price: 800 }
]
}
What does the following query using $elemMatch return?
db.products.find( { product_code: "345678" },
{ variations: { $elemMatch: { size: L } } } )
A - Returns the complete document since MongoDB does not support partial array retrieval
B - Returns the document but with only one element in the variations array (corresponding to size L)
C - Returns the complete document but retrieves only the size field from the array
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.