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


The core components in the MongoDB package are: mongod, the core database process; mongos the controller and query router for sharded clusters; and mongo the interactive MongoDB Shell.

Q 2 - Which of the following replica sets vote in the election of a primary replica set?

A - Secondary

B - Hidden

C - Delayed

D - All of the above

Answer : D


All members of a replica set, unless the value of votes is equal to 0, vote in elections. This includes all delayed, hidden and secondary-only members.

Answer : D


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

Q 4 - What does the following query do when performed on the posts collection?

db.posts.update({_id:1},{Title:This is post with ID 1"})

A - Updates the Title of the post

B - Updating a document is possible only with $set

C - Replaces the complete document with _id as 1 with the document specified in second parameter

D - Syntax error

Answer : C


Updating a document without using $set replaces the entire document with whatever document is specified in second parameter.

Q 5 - You can implement a multi-document transaction in MongoDB using which of the following concept?

A - Tailable Cursor

B - Two Phase Commits

C - Compound Indexing

D - Multi Document Transaction is not supported by MongoDB

Answer : B


Operations on a single document are always atomic with MongoDB databases; however, operations that involve multiple documents, which are often referred to as “multi-document transactions”, are not atomic.

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


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:

Q 7 - What is the minimum sensible number of voting nodes to a replica set?

A - 2

B - 3

C - 4

D - 5

Answer : B


The minimum number of sensible number of voting nodes is 3.

Q 8 - Which of the following command is used to get all the indexes on a collection?

A - db.collection.getIndexes()

B - db.collection.showIndexes()

C - db.collection.findIndexes()

D - db.showIndexes()

Answer : A


db.collection.getIndexes() is the correct choice.

Q 9 - In a sharded replica set environment, w defines the level and kind of write concern. Which of the following values of w specifies to return success only after a majority of voting members have acknowledged?

A - n

B - majority

C - m

D - major

Answer : B


For replica sets, if you specify the special majority value to w option, write operations will only return successfully after a majority of the voting members of the replica set have acknowledged the write operation.

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


The $elemMatch operator limits the contents of an array field from the query results to contain only the first element matching the $elemMatch condition.