C100DEV

C100DEV practice questions, page 3 of 4, with answer review and explanations.

Question 11

Given the following documents in a collection and given a unique index on the n field:{ _id: 1, n: ‘Apple’, p: 0.75, c: ‘Green’ },{ _id: 2, n: ‘Orange’, p: 0.85, c: ‘Orange’, q: 14 },{ _id: 3, n: [1,3,5,7], c: 42 },{ _id: 9, n: Green, c: 42 }What document can successfully be added in the same collection?

  1. { _id: 4, n: ‘Banana’, p: 0.75, c: ‘Yellow’ }
  2. { _id: 5, n: ‘Apple’, p: 0.85, c: ‘Orange’, q: 14 }
  3. { _id: 3, n: ‘Mango’, c: 42}
  4. { _id: 2, n: ‘Banana’, p: 0.75, c: ‘Green’ }

Question 12

Given the following explain plan:What statement is true for this explain plan?

  1. This is using an index.
  2. This has a sort stage with index support.
  3. This is not using an index.
  4. This uses an index in reverse direction.

Question 13

Given the following documents in the orders collection:What mongosh command will find a document with status order placed?

  1. db.orders.find_one( {status:“Order Placed”} )
  2. db.orders.findOne( {status:“Order Placed”} )
  3. db.orders.findone( {status:“Order Placed”} )
  4. db.orders.find_One( {status:“Order Placed”} )

Question 14

A collection named products contains 100 documents.What method should be used to get all results from a cursor using mongosh?

  1. db.products.findAll();
  2. db.products.forEach().toArray();
  3. db.products.find().toArray();
  4. db.products.find()[];

Question 15

Given the following schema sample in the inventory collection (with 1 million documents):{ “_id” : 1, “item” : “Apple”, “type” : “fruit”, “quantity” : 500 }What operations may become slower if the index {“item”: 1, “quantity”: 1} is created on this collection?

  1. db.inventory.find({“quantity”: {$gte: 250, $lte: 400}})
  2. db.inventory.updateMany({{“type”: “food” }, {$set: {“status” : “BackOrder”}}})
  3. db.inventory.updateMany({{“type”: “fruit” }, {$inc: {“quantity” : 100}}})
  4. db.inventory.find({“item”: “Apple”})