MongoDB MCQ Questions - Collection
This section focuses on "Collection" in MongoDB. These Multiple Choice Questions (MCQs) should be practiced to improve the MongoDB skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.
1. A __________ is a grouping of MongoDB documents.
A. database
B. node
C. collection
D. table
View Answer
Ans : C
Explanation: A collection is a grouping of MongoDB documents.
2. What is true about collection?
A. Documents within a collection can have different fields.
B. A collection is the equivalent of a table in a relational database system.
C. A collection exists within a single database.
D. All of the above
View Answer
Ans : D
Explanation: All of the above are true about collection.
3. MongoDB ____________ is used to create collection.
A. db.insertCollection(name, options)
B. db.createCollection(name, options)
C. db.useCollection(name, options)
D. db.Collection(name, options)
View Answer
Ans : B
Explanation: MongoDB db.createCollection(name, options) is used to create collection.
4. How many options parameter there during create collection?
A. 1
B. 2
C. 3
D. 4
View Answer
Ans : D
Explanation: There are 4 option parameter : capped, autoIndexId, size, max
5. MongoDB ___________ is used to drop a collection from the database.
A. db.dropCollection()
B. db.collection.delete()
C. db.collection.drop()
D. db.deleteCollection()
View Answer
Ans : C
Explanation: MongoDB db.collection.drop() is used to drop a collection from the database.
6. drop() method will return _____, if the selected collection is dropped successfully, otherwise it will return ___________.
A. true, true
B. false, false
C. true, false
D. false, true
View Answer
Ans : C
Explanation: drop() method will return true, if the selected collection is dropped successfully, otherwise it will return false.
7. Type of parameter Name is?
A. String
B. Integer
C. Boolean
D. Array
View Answer
Ans : A
Explanation: Name type is String and Name of the collection to be created
8. Type of optional field capped is?
A. String
B. Document
C. Number
D. Boolean
View Answer
Ans : D
Explanation: If true, enables a capped collection. Capped collection is a fixed size collection that automatically overwrites its oldest entries when it reaches its maximum size. If you specify true, you need to specify size parameter also.
9. Default value of autoIndexId is?
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : B
Explanation: Default value is false.
10. Size specifies a maximum size in bytes for a capped collection.
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : A
Explanation: Yes, Specifies a maximum size in bytes for a capped collection.
Discussion