This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “ObjectId”.
1. Object_Id is similar to _________ key in Relational Databases.
a) primary
b) secondary
c) composite
d) all of the mentioned
View Answer
Explanation: Object_Id is unique and cannot be changed.
2. Which of the field is reserved for use as a primary key?
a) _id
b) _uid
c) _uuid
d) All of the mentioned
View Answer
Explanation: ID value value must be unique in the collection, is immutable, and may be of any type other than an array.
3. Point out the wrong statement.
a) The field names cannot start with the dollar sign ($) character
b) The field names cannot contain the dot (.) character
c) The field names cannot contain the null character
d) None of the mentioned
View Answer
Explanation: Documents have certain restrictions on field names.
4. To ensure functioning replication, do not store values that are of the _______ regular expression type in the _id field.
a) JSON
b) XML
c) JScript
d) None of the mentioned
View Answer
Explanation: The _id field may contain values of any BSON data type, other than an array.
5. The ______ field is always the first field in the document.
a) _id
b) id
c) Ob_id
d) None of the mentioned
View Answer
Explanation: Updates that include renaming of field names may result in the reordering of fields in the document.
6. __________ returns the JavaScript representation in the form of a string literal.
a) toStringJava()
b) toString()
c) String()
d) none of the mentioned
View Answer
Explanation: In previous versions, toString() returns the hexadecimal string representation, which as of version 2.2 can be retrieved by the str property.
7. Which of the following query is used to generate a new ObjectId, use the ObjectId() constructor with no argument?
a) x = ObjectIdAdd()
b) x = addObjectId()
c) x = ObjectId()
d) none of the mentioned
View Answer
Explanation: ObjectId() constructor is used with no argument for new object.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Check Information Technology Books
- Practice Programming MCQs
- Apply for Programming Internship
- Check MongoDB Books