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

Explanation

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

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

Answer : B

Explanation

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

Q 5 - You can implement a multi-document transaction in MongoDB using which of the following concept?

A - Tailable Cursor

B - Two Phase Commits

C - Compound Indexing

D - Multi Document Transaction is not supported by MongoDB

Answer : B

Explanation

Operations on a single document are always atomic with MongoDB databases; however, operations that involve multiple documents, which are often referred to as “multi-document transactions”, are not atomic.

Q 6 - What is the equivalent command in MongoDB for the following SQL query?

SELECT * FROM posts WHERE author like "%john%"

A - db.posts.find( { author: /john/ } )

B - db.posts.find( { author: {$like: /john/} } )

C - db.posts.find( { $like: {author: /john/} } )

D - db.posts.find( { author: /^john^/ } )

Answer : A

Explanation

db.posts.find( { author: /john/ } )

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.

Answer : B

Explanation

The query in option 2, first of all groups the records by _id as author. This will group all the posts with same author and calculate the sum. Now that we have the sum with us, we are filtering on this count being greater than 1 in the next $match statement.

Q 9 - In a sharded replica set environment, w defines the level and kind of write concern. Which of the following values of w specifies to return success only after a majority of voting members have acknowledged?

A - n

B - majority

C - m

D - major

Answer : B

Explanation

For replica sets, if you specify the special majority value to w option, write operations will only return successfully after a majority of the voting members of the replica set have acknowledged the write operation.

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