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

Answer : B

Explanation

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.

Answer : A

Explanation

$type is used for all the operations involving checking the type of a field in MongoDB. 10 represents the BSON value for null.

Answer : C

Explanation

When the mongo shell interprets this query, it will override the first condition $gt and consider only the $lt one. To apply both the less than and greater than condition, you will have to use the $and operator.

Answer : C

Explanation

You cannot insert two documents with the same _id field. The value of _id field should be unique.

Q 5 - Which of the following operator can be used to limit the number of documents in an array field of a document after an update is performed?

A - $push along with $each, $sort and $slice

B - $removeFromSet

C - $arrayLimit

D - None of the above

Answer : A

Explanation

You can iterate over all the array elements using $each, slice them using $slice and then push them back to the document using $push.

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 - What is the minimum sensible number of voting nodes to a replica set?

A - 2

B - 3

C - 4

D - 5

Answer : B

Explanation

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

Answer : A

Explanation

MongoDB cannot create a unique index on the specified index field(s) if the collection already contains data that would violate the unique constraint for the index. The syntax for the same is db.collection.createIndex( { a: 1 }, { unique: true } )

Q 9 - Which of the tags in a replica set configuration specify the operations to be read from the node with the least network latency?

A - primaryPreferred

B - secondaryPreferred

C - nearest

D - netLatency

Answer : C

Explanation

Operations read from member of the replica set with the least network latency, irrespective of the member’s type.

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