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

Answer : C

Explanation

The mongoimport tool imports content from an Extended JSON, CSV, or TSV export created by mongoexport, or potentially, another third-party export tool.

Q 3 - Which of the following operations on a single document will operate atomically?

A - update

B - $push

C - Both a and b

D - None of the above

Answer : C

Explanation

Both the update and $push operators will operate in an atomic way.

Q 4 - What does the following query do when performed on the posts collection?

db.posts.update({_id:1},{Title:This is post with ID 1"})

A - Updates the Title of the post

B - Updating a document is possible only with $set

C - Replaces the complete document with _id as 1 with the document specified in second parameter

D - Syntax error

Answer : C

Explanation

Updating a document without using $set replaces the entire document with whatever document is specified in second parameter.

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 - For capped collection, cursors which do not automatically close and remain open after the client exhausts the results are called:

A - Capped Cursors

B - Tailable Cursors

C - Open Cursors

D - Indexing Cursors

Answer : B

Explanation

By default, MongoDB will automatically close a cursor when the client has exhausted all results in the cursor. However, for capped collections you may use a Tailable Cursor that remains open after the client exhausts the results in the initial cursor.

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 - Given the following posts document:

{
 "_id" : 1, 
 "post_text" : "This post does not matter�, 
  �tags�: [ "tutorial", "fun", "learning"],
  // rest of the document
}

What will be the output of following query:

db.posts.aggregate( [ { $unwind : "$tags" } ] )

A - Return three separate documents for three separate tags

B - Arranges the tags (wind) in ascending order

C - Arranges the tags (wind) in descending order

D - Returns one document but converts the tags array in an object

Answer : A

Explanation

Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element.

Q 9 - Which format/standard is used by MongoDB internally to store documents?

A - BSON

B - JSON

C - JSON - Extended

D - B+ Trees

Answer : A

Explanation

MongoDB uses BSON, a binary object format similar to, but more expressive than JSON.

Q 10 - Which index is used to index the content stored in arrays?

A - Multikey Index

B - Compound Index

C - Text Index

D - Sparse Index

Answer : A

Explanation

MongoDB uses multikey indexes to index the content stored in arrays. If you index a field that holds an array value, MongoDB creates separate index entries for every element of the array.


mongodb_questions_answers.htm

Advertisements