Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

_________ is used to view statistics about the query plan for a given query.(a) db.explain()(b) cursor.explain()(c) cursor.explainstats()(d) all of the mentionedI had been asked this question during an interview.This question is from Analyze Query Performance topic in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct CHOICE is (b) cursor.explain()

To elaborate: This INFORMATION can HELP as you develop indexing strategies.

2.

A ________ query plan has returned a threshold number of matching results.(a) execution(b) unordered(c) ordered(d) none of the mentionedThis question was posed to me during an interview.My query is from Analyze Query Performance in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Correct answer is (c) ORDERED

Easiest EXPLANATION: An ordered query plan has RETURNED all the matching results.

3.

_____can modify specific fields of an existing document or documents or replace an existing document entirely, depending on the update parameter.(a) modify()(b) update()(c) find()(d) none of the mentionedI had been asked this question in an online quiz.I'm obligated to ask this question of Analyze Query Performance in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct CHOICE is (b) update()

Explanation: By DEFAULT, the update() method UPDATES a single document.

4.

The update() method uses the _______ command, which uses the default write concern.(a) find(b) read(c) update(d) modifyI have been asked this question during an interview.The query is from Analyze Query Performance topic in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right OPTION is (c) update

Easy explanation: The update() METHOD RETURNS an object that contains the status of the OPERATION.

5.

Point out the correct statement.(a) An equality match on the unique _id field is less selective as it can match at most one document(b) The selectivity of regular expressions depends on the expressions themselves(c) Less selective queries can use indexes effectively or even at all(d) All of the mentionedThis question was addressed to me in an interview.This question is from Analyze Query Performance in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Correct option is (b) The SELECTIVITY of regular expressions DEPENDS on the expressions themselves

The best EXPLANATION: If an index exists for the FIELD, then MongoDB matches the regular expression against the values in the index, which can be FASTER than a collection scan.

6.

The ________ message is used to update a document in a collection.(a) UPDATE(b) OP_UPDATE(c) OP_UPDATES(d) All of the mentionedThis question was posed to me in exam.The query is from Analyze Query Performance topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT OPTION is (b) OP_UPDATE

The best explanation: Only the OP_QUERY and OP_GET_MORE messages RESULT in a RESPONSE from the database.
7.

___________ is used to determine whether a query is a covered query.(a) explainstats()(b) explain()(c) explainall()(d) all of the mentionedI have been asked this question in my homework.The origin of the question is Analyze Query Performance in section MongoDB CRUD Concepts and Operation of MongoDB

Answer» RIGHT ANSWER is (B) explain()

The BEST explanation: db.collection.explain() provides information on the EXECUTION of other operations, such as db.collection.update().
8.

With an __________ write concern, MongoDB does not acknowledge the receipt of write operations.(a) Nacknowledged(b) Acknowledgement(c) Acknowledged(d) UnacknowledgedI got this question by my college director while I was bunking the class.This is a very interesting question from Write operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT choice is (d) UNACKNOWLEDGED

Explanation: Unacknowledged is SIMILAR to ERRORS ignored.
9.

Point out the wrong statement.(a) Query selectivity refers to how well the query predicate excludes or filters out documents in a collection(b) Query selectivity can determine whether or not queries can use indexes effectively or even use indexes at all(c) More selective queries match a larger percentage of documents(d) All of the mentionedThe question was posed to me in final exam.My question comes from Analyze Query Performance in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT option is (C) More SELECTIVE queries match a larger percentage of DOCUMENTS

Explanation: More selective queries match a smaller percentage of documents.

10.

Indexes are typically available in ______ or located sequentially on disk.(a) RAM(b) ROM(c) CMOS(d) None of the mentionedThe question was asked by my school teacher while I was bunking the class.The origin of the question is Analyze Query Performance topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT answer is (a) RAM

Explanation: QUERYING only the index can be much FASTER than querying DOCUMENTS outside of the index.

11.

MongoDB does not ___________ modifications made before the wtimeout interval expired.(a) commit(b) rollback(c) save(d) all of the mentionedI have been asked this question by my college director while I was bunking the class.The origin of the question is Write operations topic in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Correct ANSWER is (b) rollback

The best I can explain: The driver’s ability to detect NETWORK errors DEPENDS on the system’s networking CONFIGURATION.

12.

Clients can set a __________ value as part of a replica acknowledged write concern.(a) timeout(b) wtimeout(c) waittimeout(d) none of the mentionedThis question was addressed to me in a job interview.The doubt is from Write operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Correct choice is (b) wtimeout

Easiest explanation: If the write concern is not SATISFIED in the specified interval, the operation returns an ERROR, even if the write concern will EVENTUALLY SUCCEED.

13.

_____________ is used to control mongod commits in the journal.(a) commitIntervMs(b) commitInterval(c) commitIntervalMs(d) all of the mentionedI have been asked this question by my school teacher while I was bunking the class.Asked question is from Write operations topic in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right answer is (c) commitIntervalMs

Best explanation: For REPLICA sets, write OPERATIONS are DURABLE only after a write replicates and commits to the journal on a MAJORITY of the voting members of the SET.

14.

Point out the wrong statement.(a) When a query does not include a shard key, the mongos can use cluster metadata from the config database to route the queries to shards(b) On larger clusters, scatter gather queries are unfeasible for routine operations(c) Replica sets use read preferences to determine where and how to route read operations to members of the replica set(d) None of the mwntionedI had been asked this question in semester exam.My question is taken from Write operations topic in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT ANSWER is (a) When a query does not include a SHARD key, the mongos can use cluster metadata from the config DATABASE to route the queries to shards

The explanation is: If a query does not include the shard key, the mongos must DIRECT the query to all shards in the cluster.

15.

The mongo shell and the MongoDB drivers use __________ as the default write concern.(a) Nacknowledged(b) Acknowledgement(c) Acknowledged(d) All of the mentionedI had been asked this question during a job interview.This is a very interesting question from Write operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT option is (c) Acknowledged

The explanation: MongoDB allows clients to READ documents INSERTED or MODIFIED before it commits these modifications to disk, regardless of write concern level or journaling CONFIGURATION.
16.

When inserts, updates and deletes have a _________ write concern, write operations return quickly.(a) strong(b) weak(c) average(d) very strongI had been asked this question in a national level competition.My doubt is from Write operations in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right choice is (B) weak

For EXPLANATION I would say: With STRONGER write concerns, CLIENTS wait after SENDING a write operation for MongoDB to confirm the write operations.

17.

Point out the correct statement.(a) Read operations on sharded clusters are most efficient when directed to a specific shard(b) Sharded clusters allow you to partition a data set among a cluster of mongod instances in a way that is nearly transparent to the application(c) For a sharded cluster, applications issue operations to one of the mongos instances associated with the cluster(d) All of the mentionedThe question was asked by my college professor while I was bunking the class.My question comes from Write operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct choice is (d) All of the mentioned

The BEST I can EXPLAIN: Queries to SHARDED collections should include the collection’s shard KEY.

18.

___________ concern describes the guarantee that MongoDB provides when reporting on the success of a write operation.(a) Write(b) Read(c) Update(d) None of the mentionedThe question was asked in a job interview.This key question is from Write operations in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct OPTION is (a) WRITE

For EXPLANATION I would SAY: The STRENGTH of the write concerns determine the level of guarantee.

19.

____________ is a client or database-generated identifier that uniquely identifies this message.(a) messageLength(b) responseTo(c) requestID(d) all of the mentionedThe question was posed to me in an interview.This key question is from Read Operations in section MongoDB CRUD Concepts and Operation of MongoDB

Answer» RIGHT CHOICE is (C) requestID

Explanation: For the CASE of client-generated messages, it will be RETURNED in the responseTo field of the OP_REPLY message.
20.

The __________ method returns a document that includes a metrics field.(a) db.serverStats()(b) db.serverStatus()(c) db.status()(d) all of the mentionedI have been asked this question by my college professor while I was bunking the class.My question is from Read Operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right ANSWER is (b) db.serverStatus()

EXPLANATION: The metrics field contains a cursor with NUMBER of timed out cursors since the last SERVER restart.

21.

Which of the following operator is not very selective?(a) $nine(b) $nin(c) $ain(d) None of the mentionedI got this question during a job interview.Enquiry is from Read Operations in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT ANSWER is (b) $nin

Best explanation: The inequality operators $nin and $NE are not very selective SINCE they often MATCH a large portion of the index.

22.

______________ 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 mentionedI have been asked this question by my school teacher while I was bunking the class.This is a very interesting question from Read Operations in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT OPTION is (a) cursor.batchSize(size)

To ELABORATE: Specifying 1 or a NEGATIVE number is analogous to using the LIMIT() method.
23.

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 mentionedThe question was asked in an interview.The query is from Read Operations topic in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct answer is (d) All of the mentioned

Easiest 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.

24.

To describe the message structure, a ________ like struct is used.(a) Pascal(b) C++(c) C(d) JavaThis question was posed to me at a job interview.The question is from Read Operations in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right OPTION is (C) C

Easy explanation: The STANDARD message HEADER is typed as MsgHeader. Integer constants are in capitals (e.g. ZERO for the integer VALUE of 0).

25.

Which of the following flag can be set by mongo shell?(a) Timeout(b) noTimeout(c) Time(d) None of the mentionedThis question was posed to me by my college director while I was bunking the class.Query is from Read Operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right OPTION is (b) noTimeout

For explanation: By default, the SERVER will automatically close the cursor after 10 MINUTES of INACTIVITY or if client has exhausted the cursor.

26.

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 mentionedThis question was addressed to me at a job interview.I need to ask this question from Read Operations topic in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer» RIGHT CHOICE is (b) cursor.addOption()

The explanation: You should EITHER close the cursor manually or EXHAUST the cursor.
27.

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 mentionedThe question was asked in an interview.My enquiry is from Read Operations in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right choice is (B) The MongoDB server RETURNS the query RESULTS in batches

The explanation: For most QUERIES, the FIRST batch returns 101 documents or just enough documents to exceed 1 megabyte.

28.

To suppress the _id field from the result set, specify _________ in the projection document.(a) _id: 1(b) _id: 0(c) _id: it(d) None of the mentionedThis question was addressed to me during an internship interview.Asked question is from Read Operations in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT answer is (B) _id: 0

Explanation: By DEFAULT, the _id field is INCLUDED in the results.

29.

Which of the following functionality is used for aggregation framework?(a) $match(b) $project(c) $projectmatch(d) All of the mentionedI have been asked this question during an internship interview.This question is from Read Operations topic in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right answer is (b) $project

Best explanation: For related projection functionality in the AGGREGATION FRAMEWORK PIPELINE, use the $project pipeline stage.

30.

Which of the following query selects documents in the records collection that match the condition { “user_id”: { $lt: 42 } }?(a) db.records.findOne( { “user_id”: { $lt: 42 } }, { “history”: 0 } )(b) db.records.find( { “user_id”: { $lt: 42 } }, { “history”: 0 } )(c) db.records.findOne( { “user_id”: { $lt: 42 } }, { “history”: 1 } )(d) db.records.select( { “user_id”: { $lt: 42 } }, { “history”: 0 } )The question was posed to me during an online interview.The origin of the question is Read Operations in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right answer is (B) db.records.find( { “user_id”: { $lt: 42 } }, { “history”: 0 } )

To elaborate: Query uses the projection { “history”: 0 } to EXCLUDE the history field from the documents in the result SET.

31.

Which of the following is the second argument to projection?(a) findOne()(b) findOne1()(c) selectOne()(d) find()I got this question during a job interview.Enquiry is from Read Operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right choice is (d) find()

Explanation: Projections are the second argument to the find() METHOD, which specifies a LIST of fields to RETURN or list fields to exclude in the RESULT documents.

32.

Point out the wrong statement.(a) sort() modifier sorts the results by age in ascending order(b) Queries in MongoDB return all fields in all matching documents by default(c) To scale the amount of data that MongoDB sends to applications, include a projection in the queries.(d) None of the mentionedThis question was posed to me during an online interview.The doubt is from Read Operations in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right choice is (c) To scale the amount of data that MONGODB SENDS to applications, include a projection in the queries.

For explanation: By PROJECTING results with a SUBSET of fields, applications reduce their NETWORK overhead and processing requirements.

33.

Which of the following method returns one document?(a) findOne()(b) findOne1()(c) selectOne()(d) all of the mentionedThe question was asked during a job interview.I'd like to ask this question from Read Operations topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT CHOICE is (a) findOne()

For explanation: MongoDB provides a db.collection.findOne() method as a SPECIAL case of FIND() that RETURNS a single document.
34.

In aggregation pipeline, the _______ pipeline stage provides access to MongoDB queries.(a) $catch(b) $match(c) $batch(d) All of the mentionedI got this question in homework.The query is from Read Operations topic in division MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Correct CHOICE is (b) $match

To ELABORATE: Operations that MODIFY existing documents (i.e. updates) use the same QUERY SYNTAX as queries to select documents to update.

35.

Point out the correct statement.(a) Queries specify criteria, or conditions, that identify the documents that MongoDB returns to the clients(b) Write operations, or queries, retrieve data stored in the database(c) The selection limits the amount of data that MongoDB returns to the client over the network(d) All of the mentionedI had been asked this question in class test.My question is taken from Read Operations topic in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct CHOICE is (a) Queries specify criteria, or CONDITIONS, that identify the DOCUMENTS that MongoDB returns to the clients

For EXPLANATION: In MongoDB, queries select documents from a single COLLECTION.

36.

The order of documents returned by a query is not defined unless you specify a ______(a) sortfind()(b) sortelse()(c) sort()(d) none of the mentionedThe question was asked during an online interview.This key question is from Read Operations topic in section MongoDB CRUD Concepts and Operation of MongoDB

Answer» RIGHT OPTION is (C) sort()

The explanation: You can modify the QUERY to impose LIMITS, skips, and sort orders.
37.

Applications can also control the behavior of write operations using _______ concern.(a) read(b) write(c) truncate(d) all of the mentionedI had been asked this question in unit test.Query is from CRUD Concepts in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct OPTION is (b) write

The explanation is: Write concern semantics allow CLIENTS to specify the assurance that MongoDB provides when reporting on the SUCCESS of a write OPERATION.

38.

MongoDB process collection of documents using _________ operations.(a) Hbase(b) Hive(c) Map-reduce(d) None of the mentionedThe question was posed to me in a job interview.This is a very interesting question from CRUD Concepts in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right choice is (c) Map-reduce

The explanation: In addition to the BASIC QUERIES, MONGODB provides several DATA aggregation FEATURES.

39.

Which of the following preference determines how the client direct read operations to the set?(a) read(b) write(c) update(d) deleteThis question was addressed to me during an interview for a job.I'd like to ask this question from CRUD Concepts topic in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct option is (a) READ

The explanation is: For replica sets and sharded CLUSTERS with replica set components, applications specify read preferences.

40.

Which of the following operation adds a new document to the users collection?(a) add(b) insert(c) truncate(d) dropThe question was posed to me in a job interview.My doubt is from CRUD Concepts in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer» RIGHT choice is (b) insert

To explain I WOULD say: For the update and delete operations, you can specify the CRITERIA to select the DOCUMENTS to update or remove.
41.

Point out the wrong statement.(a) Indexes cannot enforce uniqueness in collection(b) CRUD stands for create, read, update, and delete(c) CRUD application is the most simplest application(d) All of the mentionedThe question was asked during an interview.The query is from CRUD Concepts in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct answer is (a) INDEXES cannot ENFORCE uniqueness in collection

For explanation: Indexes may ALSO enforce uniqueness, store objects in a geospatial representation, and FACILITATE TEXT search.

42.

In MongoDB _________ operations modify the data of a single collection.(a) CRUD(b) GRID(c) READ(d) All of the mentionedI had been asked this question during an interview for a job.I need to ask this question from CRUD Concepts in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT option is (a) CRUD

Explanation: DATA MODIFICATION refers to OPERATIONS that create, update, or delete data.

43.

MongoDB stores all documents in _____________(a) tables(b) collections(c) rows(d) all of the mentionedThe question was asked during an internship interview.I want to ask this question from CRUD Concepts in division MongoDB CRUD Concepts and Operation of MongoDB

Answer» RIGHT choice is (b) collections

To explain I WOULD say: Collections are analogous to a table in relational databases.
44.

A query may include a ___________ that specifies the fields from the matching documents to return.(a) selection(b) projection(c) union(d) none of the mentionedThis question was addressed to me by my school teacher while I was bunking the class.My question is taken from CRUD Concepts topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct option is (b) projection

The best explanation: QUERIES specify CRITERIA, or conditions, that identify the documents that MongoDB RETURNS to the clients.

45.

Point out the correct statement.(a) Secondary indexes allow applications to store a view of a portion of the collection in an efficient data structure(b) MongoDB has full support for secondary indexes(c) Most indexes store an ordered representation of all values of a field or a group of fields(d) All of the mentionedI have been asked this question in my homework.Asked question is from CRUD Concepts in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

Right CHOICE is (b) MONGODB has FULL support for secondary INDEXES

To elaborate: Secondary indexes are used to enhance the performance of common queries and updates.

46.

The mongo shell loads and parses the ___________ file on startup.(a) mongo.js(b) mongoc.js(c) mongorc.js(d) all of the mentionedI have been asked this question in a national level competition.I need to ask this question from Generate Test Data topic in section MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The correct choice is (C) mongorc.js

Explanation: STORE the function in your .mongorc.js FILE.

47.

To iterate the cursor and return more documents, type _________ in the mongo shell.(a) cursor(b) it(c) next(d) none of the mentionedI got this question in my homework.I'm obligated to ask this question of Generate Test Data topic in portion MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT choice is (B) it

Easy explanation: The db.collection.find() method returns a cursor. To ACCESS the DOCUMENTS, you NEED to iterate the cursor.

48.

_id is a ________ bytes hexadecimal number which assures the uniqueness of every document.(a) 13(b) 16(c) 12(d) 10The question was asked during an interview.The query is from Generate Test Data in section MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT CHOICE is (C) 12

The best explanation: You can PROVIDE _id while inserting the document.
49.

Which of the following statement will insert 400 documents in to the testData collection?(a) insertData("test", "testData", 200)(b) insertData("test", "testData", 400)(c) insertData("test", "testData", 600)(d) all of the mentionedI got this question during an interview.I want to ask this question from Generate Test Data in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer» CORRECT option is (b) insertData("TEST", "testData", 400)

The explanation is: If the collection and DATABASE do not exist, MongoDB creates them implicitly before INSERTING DOCUMENTS.
50.

The __________ method limits the number of documents in the result set.(a) limit()(b) limitOf()(c) limitBy()(d) none of the mentionedThis question was posed to me in a national level competition.I want to ask this question from Getting Started with MongoDB in chapter MongoDB CRUD Concepts and Operation of MongoDB

Answer»

The CORRECT CHOICE is (a) limit()

For EXPLANATION I would SAY: limit() corresponds to the LIMIT STATEMENT in SQL.