C100DBA

C100DBA practice questions, page 3 of 6, with answer review and explanations.

Question 11

What is an example of a MongoDB BSON type?

  1. Class
  2. Vector
  3. Object
  4. Map

Question 12

Given a sample collection called collection where all documents have the following shape:{_id:1,a:2,b:[1,2,3]}Which two indexes will improve the performance of db.collection.find({b:2})? (Choose two.)

  1. {b:1}
  2. {b:1,a:1}
  3. {a:1,b:1}
  4. {a:1}

Question 13

Assuming correct imports, properly instantiated MongoClient called client, and given the following Java code:MongoCollection collection = client.getDatabase(“employees”).getCollection(“records”);Bson filter = eq(“name”, “Samantha Smith”);Bson update = set(“name”, “Sam Smith”);What statement correctly updates a single document in MongoDB?

  1. collection.updateSingle(filter, update);
  2. collection.updateOne(update, filter);
  3. collection.updateSingle(update, filter);
  4. collection.updateOne(filter, update);

Question 14

Given the following sample documents in products collection:{ “name” : “XPhone”, “price” : 799, “color : [ “white”, “black” ], “storage” : [ 64, 128, 256 ]},{ “name” : “XPad”, “price” : 899, “color : [ “white”, “black”, “purple” ], “storage” : [ 128, 256, 512 ]},{ “name” : “GTablet”, “price” : 899, “color : [ “blue” ], “storage” : [ 16, 64, 128, 1024 ]},{ “name” : “GPad”, “price” : 699, “color : [ “white”, “orange”, “gold”, “gray” ], “storage” : [ 128, 256, 1024 ]},{ “name” : “GPhone”, “price” : 599, “color : [ “white”, “orange”, “gold”, “gray” ], “storage” : [ 128, 256, 512 ]}Given the following query:What is the correct output of the query?

  1. { “name” : “XPad”, “price” : 899, “color : [ “white”, “black”, “purple” ], “storage” : [ 128, 256, 512 ]}{ “name” : “GTablet”, “price” : 899, “color : [ “blue” ], “storage” : [ 16, 64, 128, 1024 ]}
  2. { “name” : “XPhone”, “price” : 799, “color : [ “white”, “black” ], “storage” : [ 64, 128, 256 ]}{ “name” : “GPad”, “price” : 699, “color : [ “white”, “orange”, “gold”, “gray” ], “storage” : [ 128, 256, 1024 ]}
  3. { “name” : “GPhone”, “price” : 599, “color : [ “white”, “orange”, “gold”, “gray” ], “storage” : [ 128, 256, 512 ]}
  4. { “name” : “GTablet”, “price” : 899, “color : [ “blue” ], “storage” : [ 16, 64, 128, 1024 ]}

Question 15

Given a sample collection called collection, in which all documents have the following shape:{_id:1,a:{b:[1,2,3],c:”example”}}And the following query:db.collection.find({“a.b”:2})Which two indexes will improve the performance of that query? (Choose two.)

  1. {“a.b”:1,”a,c”:1}
  2. {a:1}
  3. {”a,c”:1,“a.b”:1}
  4. {“a.b”:1}