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

Explanation

A blank document is valid in MongoDB. However, rest of the three documents have some or the other problem. Option b has “=”, Option c has “;” and Option d has an incorrect array format. It should be a sub-document instead.

Q 2 - What is the output of the following program?

A - 60 s

B - 100 ms

C - 1 s

D - 100 s

Answer : A

Explanation

In the default configuration, MongoDB writes data to the main data files on disk every 60 seconds.

Answer : D

Explanation

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

Answer : B

Explanation

{multi:true} should be used for this purpose. By default, MongoDB will update only the first document.

Q 5 - Which of the following methods can be used on a cursor object?

A - cursor.next()

B - cursor.hasNext()

C - cursor.forEach()

D - All of the above

Answer : D

Explanation

All of the above methods can be used on a cursor object.

Answer : D

Explanation

There is no system collection to store database preferences.

Q 7 - What does the output x of the following MongoDB aggregation query result into:

db.posts.aggregate( [ { $group: { _id: "$author", x: { $sum: “$likes” } } } ] )

A - Average of likes on all the posts of an author, grouped by author

B - Number of posts by an author

C - Sum of likes on all the posts by an author, grouped by author

D - Sum of likes on all the posts by all the authors

Answer : C

Explanation

The above query first does a grouping on author field and then calculates the number of likes on all the posts that were grouped together.

Q 8 - Which of the following aggregation commands in MongoDB does not support sharded collections?

A - aggregate

B - mapReduce

C - group

D - All of the above

Answer : C

Explanation

The group command in MongoDB groups documents in a collection by the specified key and performs simple aggregation functions, such as computing counts and sums. It is the most basic one and does not support such sharding concepts.s

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