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

Explanation

MongoDB provides specific supports for functionalities related to 2d and 3d geospatial problems.

Q 2 - Within how much time does MongDB writes are written to the journal?

A - 60 s

B - 100 ms

C - 1 s

D - 100 s

Answer : B

Explanation

Writes are physically written to the journal within 100 milliseconds, by default.

Answer : A

Explanation

The $gt, $lt and related operators can be applied for string manipulations too. They work in the same manner as they would work on numeric values.

Q 4 - Consider that the posts collection contains an array called ratings which contains ratings given to the post by various users in the following format:

{
         _id: 1,
         post_text: “This is my first post”,
         ratings: [5, 4, 2, 5],
         //other elements of document 			
}

Which of the following query will return all the documents where the array ratings contains at least one element between 3 and 6?

A - db.inventory.find( { ratings: { $elemMatch: { $gt: 3, $lt: 6 } } } )

B - db.inventory.find( { ratings: { ratings: { $gt: 5, $lt: 9 } } } )

C - db.inventory.find( { ratings: { ratings.$: { $gt: 5, $lt: 9 } } } )

D - db.inventory.find( { ratings: { $elemMatch: { $gte: 3, $lte: 6 } } } )

Answer : A

Explanation

$elemMatch operator is used to specify multiple criteria on the elements of an array such that at least one array element satisfies all the specified criteria.

Q 5 - If the value of totalKeysExamined is 30000 and the value of totalDocsExamined is 0, which of the following option is correct?

A - The query used an index to fetch the results

B - The query returned 30000 documents after scanning the documents

C - The query returned 0 documents

D - None of the above

Answer : A

Explanation

When an index covers a query, the explain result has an IXSCAN stage that is not a descendant of a FETCH stage, and in the executionStats, the totalDocsExamined is 0.

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.

Answer : A

Explanation

The above query basically matches all the documents having likes between 100 and 200. After that, it just specifies that aggregation is not to be done with any specific column (_id:null) and increments the count every time. Thus calculating the total such posts.

Q 8 - What is a replica set node which does not maintain its own data but exists only for voting purpose called?

A - Secondary

B - Arbiter

C - Delayed

D - Hidden

Answer : B

Explanation

We may add an extra mongod instance to a replica set as an arbiter. Arbiters do not maintain a data set. Arbiters only exist to vote in elections. If your replica set has an even number of members, add an arbiter to obtain a majority of votes in an election for primary. Arbiters do not require dedicated hardware

Q 10 - Which of the following operator can be used to control the number of items of an array that a query returns?

A - $

B - $elemMatch

C - $slice

D - MongoDB does not support partial retrieval of items from an array

Answer : C

Explanation

The $slice operator controls the number of items of an array that a query returns.


mongodb_questions_answers.htm

Advertisements