MongoDB Questions and Answers – Read Operations – 2

«
»

This set of MongoDB Inteview Questions and Answers for freshers focuses on “Read Operations – 2”.

1. Which of the following flag can be set by mongo shell?
a) Timeout
b) noTimeout
c) Time
d) None of the mentioned
View Answer

Answer: b
Explanation: By default, the server will automatically close the cursor after 10 minutes of inactivity or if client has exhausted the cursor.

2. Point out the correct statement.
a) Intervening read operations on a document may result in a cursor that returns a document more than once if that document has changed
b) The MongoDB server returns the query results in batches
c) Subsequent batch size is 50 megabytes
d) None of the mentioned
View Answer

Answer: b
Explanation: For most queries, the first batch returns 101 documents or just enough documents to exceed 1 megabyte.

advertisement

3. Which of the following will display complete list of available cursor flags?
a) cursor.Option()
b) cursor.addOption()
c) cursor.addOptions()
d) all of the mentioned
View Answer

Answer: b
Explanation: You should either close the cursor manually or exhaust the cursor.

4. To describe the message structure, a ________ like struct is used.
a) Pascal
b) C++
c) C
d) Java
View Answer

Answer: c
Explanation: The standard message header is typed as MsgHeader. Integer constants are in capitals (e.g. ZERO for the integer value of 0).

advertisement
advertisement

5. Point out the wrong statement.
a) The MongoDB Wire Protocol is a simple socket-based, request-response style protocol
b) For queries that include a sort operation without an index, the server must load all the documents in memory to perform the sort before returning any results
c) Clients communicate with the database server through a regular TCP/IP socket
d) All of the mentioned
View Answer

Answer: d
Explanation: As you iterate through the cursor and reach the end of the returned batch, if there are more results, cursor.next() will perform a getmore operation to retrieve the next batch.

6. ______________ specifies the number of documents to return in each batch of the response from the MongoDB instance.
a) cursor.batchSize(size)
b) cursor.Size(size)
c) cursor.batch(size)
d) all of the mentioned
View Answer

Answer: a
Explanation: Specifying 1 or a negative number is analogous to using the limit() method.

advertisement

7. The __________ method returns a document that includes a metrics field.
a) db.serverStats()
b) db.serverStatus()
c) db.status()
d) all of the mentioned
View Answer

Answer: b
Explanation: The metrics field contains a cursor with number of timed out cursors since the last server restart.

8. ____________ is a client or database-generated identifier that uniquely identifies this message.
a) messageLength
b) responseTo
c) requestID
d) all of the mentioned
View Answer

Answer: c
Explanation: For the case of client-generated messages, it will be returned in the responseTo field of the OP_REPLY message.

advertisement

9. Which of the following operator is not very selective?
a) $nine
b) $nin
c) $ain
d) None of the mentioned
View Answer

Answer: b
Explanation: The inequality operators $nin and $ne are not very selective since they often match a large portion of the index.

10. An index cannot cover a query on a _______ collection when run against a mongos if the index does not contain the shard key.
a) vertical
b) sharded
c) horizontal
d) none of the mentioned
View Answer

Answer: b
Explanation: MongoDB can both match the query conditions and return the results using only the index.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

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

To practice all areas of MongoDB for interviews, Here is complete set of 1000+ Multiple Choice Questions and Answers.

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