MongoDB Questions and Answers – ObjectId

«
»

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

Answer: a
Explanation: Object_Id is unique and cannot be changed.

advertisement

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

Answer: a
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

Answer: d
Explanation: Documents have certain restrictions on field names.

advertisement
advertisement

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

Answer: d
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

Answer: a
Explanation: Updates that include renaming of field names may result in the reordering of fields in the document.

advertisement

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

Answer: b
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

Answer: c
Explanation: ObjectId() constructor is used with no argument for new object.
advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Reference Books in MongoDB.

advertisement

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter