MongoDB Online Quiz


Advertisements

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

Q 1 - The MongoDB explain() method does not support which of the following verbosity mode:

A - queryPlanner

B - executionStats

C - allPlansExecution

D - customExecutionStats

Answer : D

Explanation

The possible modes of explain() are: "queryPlanner", "executionStats", and "allPlansExecution".

Answer : C

Explanation

There is no direct way of changing the sharded key unless you dump the entire data, drop the sharded key and then re-import everything. Other all options are false. Sharding is enabled at collection level, it does not create any index by default and finally sharding environment supports regular sorting.

Answer : C

Explanation

MongoDB does not support things like ACID Transactions or atomicity across collections or relationships like SQL.

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:

A - nMatched

B - nInserted

C - nModified

D - nUpserted

Answer : D

Explanation

The nUpserted shows the number of documents that were added during the update operation.

Q 5 - Which language is MongoDB written in?

A - C++

B - Java

C - Python

D - MongoC

Answer : A

Explanation

MongoDB is written in C++.

Q 6 - Which is the correct order (lowest to highest) in which MongoDB compares the BSON types?

A - Null, Number, String and Object

B - Number, Null, String and Object

C - String, Null, Number and Object

D - Null, Number, Object and String

Answer : A

Explanation

This is the defined order in which the bson types are compared. There are various other fields as per the BSON specification which can be found here: http://docs.mongodb.org/manual/reference/bson-types/

Q 7 - Which of the following command inside aggregate command is used in MongoDB aggregation to filter the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

A - $group

B - $match

C - $aggregate

D - $sum

Answer : B

Explanation

$match filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

Q 8 - Given the following posts document:

{
 "_id" : 1, 
 "post_text" : "This post does not matter”, 
  “tags”: [ "tutorial", "fun", "learning"],
  // rest of the document
}

What will be the output of following query:

db.posts.aggregate( [ { $unwind : "$tags" } ] )

A - Return three separate documents for three separate tags

B - Arranges the tags (wind) in ascending order

C - Arranges the tags (wind) in descending order

D - Returns one document but converts the tags array in an object

Answer : A

Explanation

Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element.

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 - If you have created a compound index on (A,B, C) which of the following access pattern will not be able to utilize the index?

A - A, B, C

B - A, B

C - B, C

D - A

Answer : C

Explanation

Since the index itself starts from A, it cannot be utilized it the input query is starting with B.

mongodb_questions_answers.htm
Advertisements