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.

Questions and Answers

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 - Which is the default mode in which the explain() command runs?

A - queryPlanner

B - executionStats

C - allPlansExecution

D - customExecutionStats

Answer : A

Explanation

Default mode is "queryPlanner".

Q 3 - Which of the following command can be used to check the size of a collection named posts?

A - db.posts.stats()

B - db.posts.findStats()

C - db.posts.find({stats:1})

D - db.stats({ collection : 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.

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 are the ONLY ways to project portions of an array?

A - $elemMatch

B - $slice

C - $

D - All of the above

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

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 as well as acknowledged by at least 3 nodes. What should be the value of w?

A - 0

B - 1

C - 3

D - 7

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 SQL terminology is same as $match in MongoDB?

A - WHERE

B - HAVING

C - Both WHERE and HAVING

D - GROUP BY

Answer : C

Explanation

In MongoDB, we use $match as the aggregation operator corresponding to WHERE and HAVING condition in MongoDB.

Q 9 - We can insert multiple documents in bulk using which of the following operations:

A - initializeUnorderedBulkOp

B - initializeBulkOp

C - initializeBulk

D - initializeUnorderedBulk

Answer : A

Explanation

The initializeUnorderedBulkOp operation returns an unordered operations builder which maintains a list of operations to perform. Unordered operations means that MongoDB can execute in parallel as well as in nondeterministic order.

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

B - When the many is not very large

C - Never

D - Always

Answer : B

Explanation

If the many is very large, then we should create separate collection, else the document size would go on increasing.

mongodb_questions_answers.htm
Advertisements