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

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?

A - 64 bytes and 1024 indexes

B - 12 mega bytes and 64 indexes

C - 1024 bytes and 64 indexes

D - 1024 bytes and unlimited indexes

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.

Answer : D

Explanation

Since 100 and 200 are both inclusive, we need $gte (greater than and equal) and $lte (less than and equal).

Answer : D

Explanation

$set sets the specific fields in the matched documents or adds them as a new field if not already present.

Answer : B

Explanation

explain.executionStats.totalKeysExamined indicates the number of index entries scanned.

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?

A - 0

B - 1

C - 2

D - 7

Answer : B

Explanation

To enable the disk journaling commits, j value should always be set to 1.

Answer : 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?

A - $push

B - $wind

C - $wind.$wind

D - Can’t be reversed.

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.

A - $

B - $elemMatch

C - $slice

D - An array cannot be retrieved element wise in MongoDB.

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.

mongodb_questions_answers.htm
Advertisements