250+ TOP MCQs on Capped Collections and Answers

MongoDB Multiple Choice Questions on “Capped Collections”.

1. Which of the following collections work in a way similar to circular buffers?
a) Capped
b) Secondary
c) Sharded
d) All of the mentioned

Answer: a
Clarification: Once a collection fills its allocated space, it makes room for new documents by overwriting the oldest documents in the collection.

2. Point out the correct statement.
a) Capped collections automatically remove the oldest documents in the collection without requiring scripts or explicit remove operations
b) Capped collections do not guarantee that insertion order is identical to the order on disk
c) Capped collections does not allow updates that fit the original document size
d) All of the mentioned

Answer: a
Clarification: Document does not change its location on disk.

3. _________ stores a log of the operations in a replica set.
a) oplog.rs
b) log.rs
c) oplog
d) all of the mentioned

Answer: a
Clarification: Built-in first-in-first-out property maintains the order of events while managing storage use.

4. ___________ is also used to pre-allocate space for an ordinary collection.
a) db.createCollection.
b) db.create
c) db.createColl
d) all of the mentioned

Answer: a
Clarification: MongoDB creates a collection implicitly when the collection is first referenced in a command.

5. Point out the wrong statement.
a) Queries need an index to return documents in insertion order
b) The options document creates a capped collection or preallocates space in a new ordinary collection
c) Capped collections have maximum size or document counts that prevent them from growing beyond maximum thresholds
d) None of the mentioned

Answer: a
Clarification: Capped collections guarantee preservation of the insertion order.

  250+ TOP MCQs on Database Profiler and Answers

6. If you perform a ________ on a capped collection with no ordering specified, MongoDB guarantees that the ordering of results is the same as the insertion order.
a) find()
b) write()
c) modify()
d) none of the mentioned

Answer: a
Clarification: To retrieve documents in reverse insertion order, issue find() along with the sort() method with the $natural parameter set to -1.

7. Which of the following should is used to check whether collection is capped or not?
a) isCAP()
b) isCapped()
c) isColl()
d) none of the mentioned

Answer: b
Clarification: Use the isCapped() method to determine if a collection is capped, as: db.collection.isCapped().

8. ___________ convert a non-capped collection to a capped collection.
a) ToCapped
b) convertToCap
c) convertToCapped
d) none of the mentioned

Answer: c
Clarification: convertToCapped takes an existing collection () and transforms it into a capped collection with a maximum size in bytes, specified by the size argument ().

9. _________ command creates the capped collection and imports the data.
a) CollectionAsCapped
b) cloneCollection
c) cloneCollectionAsCapped
d) None of the mentioned

Answer: c
Clarification: MongoDB does not support the convertToCapped command in a sharded cluster.

10. Which of the following command obtains a global write lock and will block other operations until it has completed?
a) ToCapped
b) isCapped
c) convertToCapped
d) None of the mentioned

Answer: b
Clarification: If the capped size specified for the capped collection is smaller than the size of the original uncapped collection, then MongoDB will overwrite documents in the capped collection based on the insertion order, or first in, first out order.

  250+ TOP MCQs on Replica Set Deployment Architectures and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top