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

Q 3 - Consider that our posts collection contains an array field called tags that contains tags that the user enters.

{
            _id: 1,
            tags: [“tutorial”, “fun”, “learning”],
            post_text: “This is my first post”,	
            //other elements of document  	
} 

Which of the following commands will find all the posts that have been tagged as tutorial.

A - db.posts.find( { tags : "tutorial" } );

B - db.posts.find( { tags : ["tutorial"] } );

C - db.posts.find( { $array : {tags: "tutorial"} } );

D - db.posts.findInArray( { tags : "tutorial" } );

Answer : A

Explanation

Searching an array is no different than searching a normal field. Hence the first option.

Answer : B

Explanation

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

Q 5 - Which option should be used with findAndModify() command to return the modified document instead of the pre-modification document?

A - findAndModify by default returns the pre-modification document

B - Set {new : true}

C - Use the POST version of findAndModify called findAndModifyPost

D - Both b and c are valid

Answer : B

Explanation

When true, returns the modified document rather than the original. The findAndModify() method ignores the new option for remove operations. The default is false.

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

You have to give state and city as the key to group by and then calculate the sum of the population in each city.

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 - We can insert multiple documents in bulk using which of the following operations:

A - initializeUnorderedBulkOp

B - initializeBulkOp

C - initializeBulk

D - initializeUnorderedBulk

Answer : A

Explanation

The initializeUnorderedBulkOp operation returns an unordered operations builder which maintains a list of operations to perform. Unordered operations means that MongoDB can execute in parallel as well as in nondeterministic order.

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