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 : C

Explanation

$set is used to set the value of a particular field in a document. The syntax of set is $set:{column_name : column_value}. Also, {multi:true} is needed to update all the documents. Otherwise only the first found document is updated.

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

Explanation

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 : A

Explanation

The efficiency of a MongoDB database depends on how well the database is designed depending on the application usage. The schema should be designed based on how the data access patterns are.

Answer : A

Explanation

When you specify upsert: true for an update operation and no matching documents are found, MongoDB creates a new document.

Answer : B

Explanation

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

Q 6 - What is the default size of a GridFS chunk?

A - 16 MB

B - 255 K

C - 1 MB

D - 2 MB

Answer : B

Explanation

By default GridFS limits chunk size to 255k.

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.

Q 8 - In a replica set, a ________ number of members ensures that the replica set is always able to select a primary.

A - Odd

B - Even

C - Depends on the application architecture

D - 2

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:

A - mongod --replSet "rs0"

B - mongod --repl "rs0"

C - mongod "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.

Answer : A

Explanation

The $slice operation selects the document collection identified by a field named field that holds value and returns the number of elements specified by the value of count from the array stored in the array field.

mongodb_questions_answers.htm
Advertisements