Loading, please wait...

MongoDB MCQ Quiz (Multiple Choice Questions And Answers)

Search here for MCQs

Are you preparing for the next job interviews? If yes, trust me this post will help you also we'll suggest you check out a big collection for Programming Full Forms that may help you in your interview:

List of Programming Full Forms 

16. Which index is used to index the content stored in arrays?

  • Multikey Index
  • Compound Index
  • Text Index
  • Sparse Index

17. 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 rating array contains elements that in some combination satisfy the query conditions?

  • db.inventory.find( { ratings: { $elemMatch: { $gt: 3, $lt: 6 } } } )
  • db.inventory.find( { ratings: { ratings: { $gt: 5, $lt: 9 } } } )
  • db.inventory.find( { ratings: { ratings.$: { $gt: 5, $lt: 9 } } } )
  • db.inventory.find( { ratings: { $elemMatch: { $gte: 3, $lte: 6 } } } )

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

  • findAndModify by default returns the pre-modification document
  • Set {new : true}
  • Use the POST version of findAndModify called findAndModifyPost
  • Both b and c are valid

19. Which of the following collections are used by MongoDB to store GridFS data?

  • fs.files and fs.chunks
  • fs.grid and fs.chunks
  • fs.parts and fs.files
  • fs.chunks and fs.parts

20. Which of the following methods can be used in MongoDB for relation documents?

  • Manual References
  • DBRefs
  • Both a and b
  • There is no concept of relations in documents