MongoDB MCQ Number 01235

MongoDB MCQ Set 1

1. ______ expressions ignores the duplicate entries in each input array and the order of the elements.
a) set
b) boolean
c) aggregate
d) none of the mentioned

Answer

Answer: a [Reason:] If the set operation returns a set, the operation filters out duplicates in the result to output an array that contains only unique entries.

2. Point out the correct statement :
a) To avoid parsing ambiguity if the argument is a literal array, you must wrap the literal array in a $lits expression or keep the outer array that designates the argument list
b) Expressions cannot include field paths and system variables, literals, expression objects, and expression operators
c) Operator expressions are similar to functions that take arguments
d) All of the mentioned

Answer

Answer: c [Reason:] In general, these expressions take an array of arguments and have the following form: { : [ , … ] }

3. ________ returns true if the input sets have the same distinct elements.
a) $setUnion
b) $setDifference
c) $setEquals
d) None of the mentioned

Answer

Answer: c [Reason:]$setEquals accepts two or more argument expressions.

4. Which of the following accepts any number of argument expression ?
a) $setIntersection
b) $setDifference
c) $setEquals
d) None of the mentioned

Answer

Answer: a [Reason:]$setIntersection returns a set with elements that appear in all of the input sets.

5. Point out the wrong statement :
a) Boolean expressions evaluate their argument expressions as booleans and return a boolean as the result
b) In addition to the false boolean value, Boolean expression evaluates as false the following: null, 0, and undefined values
c) Set expressions performs set operation on arrays, treating arrays as sets
d) None of the mentioned

Answer

Answer: d [Reason:] The Boolean expression evaluates all other values as true, including non-zero numeric values and arrays.

6. ________ returns a set with elements that appear in any of the input sets.
a) $setIntersection
b) $setDifference
c) $setEquals
d) $setUnion

Answer

Answer: d [Reason:]$setUnion performs set operation on arrays, treating arrays as sets.

7. Which of the following performs a relative complement of the second set relative to the first?
a) $setIntersection
b) $setDifference
c) $setEquals
d) $setUnion

Answer

Answer: a [Reason:]$setDifference returns a set with elements that appear in the first set but not in the second set.

8. $setIsSubset returns _______ if all elements of the first set appear in the second set, including when the first set equals the second set.
a) Null
b) True
c) False
d) None of the mentioned

Answer

Answer: c [Reason:]$setIsSubset accepts exactly two argument expressions.

9. _______ accepts only single argument expression.
a) $setIsSubset
b) $bool
c) $anyElementTrue
d) None of the mentioned

Answer

Answer: c [Reason:]$anyElementTrue returns true if any elements of a set evaluate to true; otherwise, returns false.

10. $allElementsTrue returns true if no element of a set evaluates to :
a) false
b) true
c) 0
d) 1

Answer

Answer: a [Reason:] An empty array returns true.

MongoDB MCQ Set 2

1. Which of the following returns a substring of a string ?
a) $subs
b) $substring
c) $substr
d) None of the mentioned

Answer

Answer: c [Reason:] $substr accepts three expressions as arguments: the first argument must resolve to a string, and the second and third arguments must resolve to integers.

2. Point out the correct statement :
a) $substr ends at a specified index position up to a specified length
b) $toLower converts a string to lowercase
c) $gtle returns true if the first value is greater than or equal to the second
d) All of the mentioned

Answer

Answer: b [Reason:] If the argument resolves to null, $toLower returns an empty string “”.

3. Which of the following accepts a single argument expression ?
a) $toLow
b) $toUpper
c) $toEqual
d) None of the mentioned

Answer

Answer: b [Reason:] $toUpper converts a string to uppercase.

4. Which of the following performs case-insensitive string comparison ?
a) $strcasecmpequals
b) $strcasecmp
c) $strcmp
d) None of the mentioned

Answer

Answer: a [Reason:] $strcasecmp returns 0 if two strings are equivalent.

5. Point out the wrong statement :
a) { $meta: “textScore” } expression is only meaningful in a pipeline that includes a $match stage with a $text query
b) The { $meta: “textScore” } expression is the only expression that the $sort stage accepts
c) $toLower only has a well-defined behavior for strings of ASCII characters
d) None of the mentioned

Answer

Answer: d [Reason:] A $meta expression has the following syntax:{ $meta: }.

6. _______ is used for access text search metadata.
a) $text
b) $metades
c) $meta
d) All of the mentioned

Answer

Answer: c [Reason:] $meta returns the metadata associated with a document in a pipeline operations.

7. Which of the following accepts named parameters ?
a) $reduce
b) $letnum
c) $let
d) None of the mentioned

Answer

Answer: d [Reason:] $let defines variables for use within the scope of a subexpression and returns the result of the subexpression.

8. _______ returns the number of elements in the array.
a) $number
b) $size
c) $div
d) None of the mentioned

Answer

Answer: b [Reason:] The argument for $size can be any expression as long as it resolves to an array.

9. _________ returns a value without parsing.
a) $string
b) $literal
c) $characters
d) None of the mentioned

Answer

Answer: b [Reason:] Use for values that the aggregation pipeline may interpret as an expression.

10. db.collection.aggregate() returns a _______ and can return result sets of any size.
a) replica
b) cursor
c) document
d) $subtract

Answer

Answer: b [Reason:] The aggregate command can return results as a cursor or store the results in a collection, which are not subject to the size limit.

MongoDB MCQ Set 3

1. Which of the following storage engine is supported by default ?
a) MMAPv1
b) WiredTiger
c) WirelessTiger
d) All of the mentioned

Answer

Answer: a [Reason:] MongoDB includes support for two storage engines: MMAPv1, the storage engine available in previous versions of MongoDB, and WiredTiger.

2. Point out the correct statement :
a) Replica set configuration is complex
b) MongoDB includes support for two storage engines
c) MongoDB includes support for more than three storage engines
d) All of the mentioned

Answer

Answer: b [Reason:] MMAPv1 provides collection-level locking.

3. All collections have a unique ________ lock that allows multiple clients to modify documents in different collections at the same time.
a) writer
b) readers-writer
c) readers
d) all of the mentioned

Answer

Answer: b [Reason:] Each database has a readers-writer lock that allows concurrent read access to a database, but gives exclusive access to a single write operation per database.

4. _________ supports concurrent access by readers and writers to the documents in a collection.
a) MMAPv1
b) WiredTiger
c) WirelessTiger
d) All of the mentioned

Answer

Answer: b [Reason:] Clients can read documents while write operations are in progress, and multiple threads can modify different documents in a collection at the same time.

5. Point out the correct statement :
a) MongoDB distributions are currently available for Mac OS X, Linux, Windows Server 2012, Windows Server 2008 R2 64bit, Windows 7 (64 bit), Windows Vista, and Solaris
b) The MongoDB distribution for Solaris include support for the WiredTiger storage engine
c) mongod will not start if dbPath contains data files created by a storage engine
d) None of the mentioned

Answer

Answer: b [Reason:] The MongoDB distribution for Solaris does not include support for the WiredTiger storage engine.

6. MongoDB uses ________ logging to an on-disk journal.
a) write ahead
b) read ahead
c) write once
d) read only

Answer

Answer: a [Reason:] Leave journaling enabled in order to ensure that mongod will be able to recover its data files and keep the data files in a valid state following a crash.

7. _______ concern describes the guarantee that MongoDB provides when reporting on the success of a write operation.
a) Write
b) Read
c) Read only
d) SSD

Answer

Answer: a [Reason:] The strength of the write concerns determine the level of guarantee.

8. The ________ command returns information regarding the number of open connections
a) connPoolStats
b) connStats
c) serverstats
d) none of the mentioned

Answer

Answer: a [Reason:] To avoid overloading the connection resources of a single mongod or mongos instance, ensure that clients maintain reasonable connection pool sizes.

9. ________ do not typically provide sufficient performance to support a MongoDB deployment
a) RAID-5
b) RAID-10
c) RAID-7
d) None of the mentioned

Answer

Answer: a [Reason:] Most MongoDB deployments should use disks backed by RAID-10.

10. Which of the following should be avoided with MongoDB Deployments ?
a) RAID-5
b) RAID-10
c) RAID-7
d) RAID-0

Answer

Answer: d [Reason:] While RAID-0 provides good write performance, it also provides limited availability and can lead to reduced performance on read operations, particularly when using Amazon’s EBS volumes.

MongoDB MCQ Set 4

1. 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 mentioned

Answer

Answer: c [Reason:] You can modify the query to impose limits, skips, and sort orders.

2. 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 mentioned

Answer

Answer: a [Reason:] In MongoDB, queries select documents from a single collection.

3. In aggregation pipeline, the _______ pipeline stage provides access to MongoDB queries.
a) $catch
b) $match
c) $batch
d) All of the mentioned

Answer

Answer: b [Reason:] Operations that modify existing documents (i.e. updates) use the same query syntax as queries to select documents to update.

4. Which of the following method returns one document?
a) findOne()
b) findOne1()
c) selectOne()
d) all of the mentioned

Answer

Answer: a [Reason:] MongoDB provides a db.collection.findOne() method as a special case of find() that returns a single document.

5. 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 mentioned

Answer

Answer: c [Reason:] By projecting results with a subset of fields, applications reduce their network overhead and processing requirements.

6. Which of the following is second argument to projection ?
a) findOne()
b) findOne1()
c) selectOne()
d) find()

Answer

Answer: d [Reason:] Projections are the second argument to the find() method,which specify a list of fields to return or list fields to exclude in the result documents.

7. 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 } )

Answer

Answer: b [Reason:] Query uses the projection { “history”: 0 } to exclude the history field from the documents in the result set.

8. Which of the following functionality is used for aggregation framework ?
a) $match
b) $project
c) $projectmatch
d) All of the mentioned

Answer

Answer: b [Reason:] For related projection functionality in the aggregation framework pipeline, use the $project pipeline stage.

9. 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 mentioned

Answer

Answer: b [Reason:] By default, the _id field is included in the results.

10. Which of the following is not a projection operator ?
a) $slice
b) $elemMatch
c) $
d) None of the mentioned

Answer

Answer: d [Reason:] For fields that contain arrays, MongoDB provides the following projection operators: $elemMatch, $slice, and $.

MongoDB MCQ Set 5

1. The __________ of a replica set affects the outcome of failover situations.
a) deployment
b) architecture
c) structure
d) all of the mentioned

Answer

Answer: a [Reason:] To support effective failover, ensure that one facility can elect a primary if needed.

2. Point out the wrong statement :
a) Administrators must apply or discard rollback data manually
b) Network partitions could not prevent the set from being able to form a majority
c) Replica sets remove “rollback” data when needed without intervention
d) None of the mentioned

Answer

Answer: b [Reason:] When a rollback does occur, it is often the result of a network partition.

3. A rollback reverts _______ operations on a former primary when the member rejoins the replica set after a failover.
a) read
b) write
c) view
d) secondary

Answer

Answer: b [Reason:] The replica set recovers from the loss of a primary by holding an election.

4. A priority __ member is a secondary that cannot become primary.
a) 0
b) 1
c) 2
d) None of the mentioned

Answer

Answer: a [Reason:] Priority 0 members cannot trigger elections.

5. Point out the correct statement :
a) Elections does not occur when the primary becomes unavailable and the replica set members autonomously select a new primary
b) A priority 1 member maintains a copy of the data set, accepts read operations, and votes in elections
c) In a two-member replica set, in one data center hosts the primary and a secondary.
d) None of the mentioned

Answer

Answer: a [Reason:] Configure a priority 0 member to prevent secondaries from becoming primary, which is particularly useful in multi-data center deployments.

6. A second data center hosts one priority 0 member that cannot become :
a) primary
b) write
c) view
d) Secondary

Answer

Answer: a [Reason:] A priority 0 member can function as a standby.

7. A ______ member maintains a copy of the primary’s data set but is invisible to client applications.
a) primary
b) delayed
c) hidden
d) none of the mentioned

Answer

Answer: c [Reason:] Hidden members are good for workloads with different usage patterns from the other members in the replica set.

8. _________ is used to read the contents of the rollback files.
a) bsondumpdata
b) bsondp
c) bsondump
d) none of the mentioned

Answer

Answer: c [Reason:] The bsondump converts BSON files into human-readable formats, including JSON.

9. The db.________ method does not display hidden members.
a) isPrima ry()
b) isMaster()
c) Master()
d) none of the mentioned

Answer

Answer: b [Reason:] Hidden members, however, may vote in elections.

10. In a sharded cluster, _______ do not interact with hidden members.
a) mongod
b) mongos
c) mongostore
d) all of the mentioned

Answer

Answer: b [Reason:] Clients will not distribute reads with the appropriate read preference to hidden members.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.