0% found this document useful (0 votes)
98 views23 pages

MongoDB Basics Quiz

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views23 pages

MongoDB Basics Quiz

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link] type of database is MongoDB?

● A) Relational Database
● B) Key-Value Database
● C) Document-Oriented Database
● D) Graph Database
Answer: C) Document-Oriented Database

[Link] is the default data storage format for documents in MongoDB?

● A) JSON
● B) BSON
● C) XML
● D) CSV
Answer: B) BSON

[Link] MongoDB, a collection is similar to which concept in relational databases?

● A) Table
● B) Row
● C) Column
● D) Index
Answer: A) Table

[Link] command is used to create a new database in MongoDB?

● A) [Link]("database_name")
● B) use database_name
● C) create database database_name
● D) [Link](database_name)
Answer: B) use database_name

[Link] of the following MongoDB methods is used to insert a single document into a
collection?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: A) [Link]()

[Link] of the following is NOT a supported data type in MongoDB?

● A) Array
● B) Integer
● C) Date
● D) Double-Array
Answer: D) Double-Array

[Link] MongoDB command retrieves all documents in a collection?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: B) [Link]()

[Link] command will delete a collection in MongoDB?

● A) [Link](collection_name)
● B) [Link]()
● C) [Link]()
● D) [Link](collection_name)
Answer: C) [Link]()

[Link] is the purpose of an index in MongoDB?

● A) To reduce storage size


● B) To improve search performance
● C) To encrypt data
● D) To create backups
Answer: B) To improve search performance

[Link] MongoDB, the unique identifier for a document is known as what?

● A) Primary Key
● B) Document Key
● C) _id Field
● D) Object Identifier
Answer: C) _id Field

[Link] the document model, how is data typically stored?

● A) In rows and columns


● B) As structured documents
● C) In key-value pairs only
● D) As JSON arrays only
Answer: B) As structured documents

[Link] data format is commonly used by MongoDB to represent documents internally?


● A) XML
● B) BSON
● C) CSV
● D) YAML
Answer: B) BSON

[Link] MongoDB, each document within a collection must contain which unique field?

● A) _document_id
● B) uniqueKey
● C) _id
● D) docID
Answer: C) _id

[Link] is a key benefit of using the document model for data storage?

● A) Supports ACID transactions only


● B) Reduces storage space by storing data as plain text
● C) Offers a flexible schema that allows fields to vary across documents
● D) Enforces a strict schema for all documents
Answer: C) Offers a flexible schema that allows fields to vary across documents

[Link] the document model, relationships between data are often represented by:

● A) Embedding documents within each other


● B) Using foreign keys
● C) SQL joins
● D) Indexing tables
Answer: A) Embedding documents within each other

[Link] of the following statements is true about MongoDB’s document model?

● A) Each document in a collection must have the same structure.


● B) Documents in a collection can have different fields.
● C) The document model enforces relational constraints.
● D) Document fields cannot store arrays.
Answer: B) Documents in a collection can have different fields.

[Link] type of data can be stored in a MongoDB document?

● A) Only strings and numbers


● B) Only arrays and integers
● C) Any type, including arrays, objects, and dates
● D) Only primitive data types
Answer: C) Any type, including arrays, objects, and dates
[Link] is one disadvantage of using embedded documents for nested data in
MongoDB?

● A) Increases performance
● B) Cannot store arrays in embedded documents
● C) Increases data redundancy
● D) Limits querying capabilities
Answer: C) Increases data redundancy

[Link] MongoDB feature allows documents to be retrieved based on their structure?

● A) Schemas
● B) Joins
● C) Indexes
● D) Aggregations
Answer: C) Indexes

[Link] MongoDB, which structure would best represent a “one-to-many” relationship


within the document model?

● A) Embedding multiple documents within a single document


● B) Storing data in separate databases
● C) Using SQL joins
● D) Storing the relationship in an external file
Answer: A) Embedding multiple documents within a single document

21. What type of architecture does MongoDB use to ensure high availability and
scalability?

● A) Master-Slave
● B) Client-Server
● C) Distributed and Sharded
● D) Centralized
Answer: C) Distributed and Sharded

22. In MongoDB, what is a replica set?

● A) A single node that holds data


● B) A group of servers that maintains the same data for redundancy
● C) A set of indexes to improve query performance
● D) A temporary data store for backups
Answer: B) A group of servers that maintains the same data for redundancy

[Link] of the following is a primary component of MongoDB’s architecture that helps


distribute data across multiple servers?
● A) Indexing
● B) Sharding
● C) Aggregation
● D) Caching
Answer: B) Sharding

[Link] is the role of a primary node in a MongoDB replica set?

● A) It acts as a backup server.


● B) It handles all write operations and coordinates with secondary nodes.
● C) It only processes read requests.
● D) It performs data validation for other nodes.
Answer: B) It handles all write operations and coordinates with secondary nodes.

[Link] MongoDB component handles read requests if the primary node is


unavailable?

● A) Arbiter
● B) Config Server
● C) Secondary Node
● D) Router
Answer: C) Secondary Node

[Link] is the role of an arbiter node in a MongoDB replica set?

● A) To store data in case of primary node failure


● B) To vote in elections without storing a copy of the data
● C) To handle all read and write operations
● D) To create indexes for query optimization
Answer: B) To vote in elections without storing a copy of the data

[Link] MongoDB component is responsible for routing requests to the appropriate


shard?

● A) Config Server
● B) Query Router (mongos)
● C) Primary Node
● D) Aggregator
Answer: B) Query Router (mongos)

[Link] does MongoDB ensure data consistency across a replica set?

● A) Using synchronous replication


● B) Through primary node elections
● C) By allowing only one node to process requests
● D) By performing read and write operations on all nodes simultaneously
Answer: A) Using synchronous replication

[Link] a sharded cluster, which component stores the metadata of the shards?

● A) Primary Node
● B) Query Router (mongos)
● C) Config Server
● D) Arbiter
Answer: C) Config Server

[Link] MongoDB process is used to manage sharded data across multiple shards?

● A) mongos
● B) mongo
● C) mongod
● D) mongoexport
Answer: A) mongos

[Link] of the following is a key feature of MongoDB that supports a flexible data
structure?

● A) Fixed schema enforcement


● B) Document-oriented storage
● C) Table-based data organization
● D) Multi-dimensional arrays only
Answer: B) Document-oriented storage

[Link] is the purpose of indexing in MongoDB?

● A) To store data redundantly


● B) To improve query performance
● C) To backup the database
● D) To ensure data consistency
Answer: B) To improve query performance

[Link] MongoDB feature allows it to scale horizontally across multiple servers?

● A) Replication
● B) Indexing
● C) Sharding
● D) Aggregation
Answer: C) Sharding

[Link] type of data model does MongoDB use?


● A) Relational model
● B) Hierarchical model
● C) Key-Value model
● D) Document model
Answer: D) Document model

[Link] MongoDB, which feature ensures high availability by maintaining multiple copies of
data?

● A) Sharding
● B) Aggregation
● C) Replication
● D) Indexing
Answer: C) Replication

[Link] feature in MongoDB allows developers to perform complex data


transformations and computations on data within a single query?

● A) Indexing
● B) Aggregation framework
● C) Sharding
● D) Clustering
Answer: B) Aggregation framework

[Link]'s capability to store arrays and sub-documents within documents is


referred to as:

● A) Structured data storage


● B) Hierarchical storage
● C) Embedded documents
● D) Normalization
Answer: C) Embedded documents

[Link] MongoDB feature allows users to conduct text searches within documents?

● A) GridFS
● B) Text indexing
● C) Aggregation
● D) Sharding
Answer: B) Text indexing

[Link] feature of MongoDB enables developers to perform CRUD operations on large


files and store files larger than the BSON document size limit?

● A) Replication
● B) GridFS
● C) Sharding
● D) Aggregation
Answer: B) GridFS

[Link] does MongoDB ensure consistency in multi-document ACID transactions?

● A) By enforcing strict schema


● B) Through replica sets
● C) By supporting ACID transactions at the document level
● D) By limiting operations to single documents only
Answer: C) By supporting ACID transactions at the document level

[Link] command is used to create a new database in MongoDB?

● A) [Link]("database_name")
● B) use database_name
● C) create database database_name
● D) [Link]("database_name")
Answer: B) use database_name

[Link] MongoDB, how is a new collection created?

● A) Automatically when a document is inserted


● B) Using the create collection command
● C) By initializing with [Link]()
● D) By manually defining the schema
Answer: A) Automatically when a document is inserted

[Link] command explicitly creates a collection with specific options in MongoDB?

● A) [Link]("collection_name", options)
● B) [Link]("collection_name", options)
● C) create collection collection_name options
● D) [Link]("collection_name", options)
Answer: A) [Link]("collection_name", options)

[Link] command is used to display all collections in a MongoDB database?

● A) [Link]()
● B) [Link]()
● C) show collections
● D) list all collections
Answer: C) show collections
[Link] happens if you attempt to use a database in MongoDB that doesn’t yet exist?

● A) MongoDB throws an error.


● B) The database is created only if a collection or document is added.
● C) MongoDB creates the database immediately.
● D) The database remains inactive until restarted.
Answer: B) The database is created only if a collection or document is added.

[Link] of the following options can be specified when creating a collection with
[Link]()?

● A) Maximum storage size and number of documents


● B) Encryption type
● C) Indexing options only
● D) File format
Answer: A) Maximum storage size and number of documents

[Link] do you delete a database in MongoDB?

● A) [Link]()
● B) delete database dbname
● C) [Link]()
● D) remove database dbname
Answer: C) [Link]()

[Link] delete a collection in MongoDB, which command should be used?

● A) drop collection_name
● B) [Link]("collection_name")
● C) db.collection_name.drop()
● D) delete collection_name
Answer: C) db.collection_name.drop()

[Link] command in MongoDB switches the context to an existing or new database?

● A) use
● B) switch
● C) select
● D) load
Answer: A) use

[Link] can you check the name of the currently selected database in MongoDB?

● A) [Link]()
● B) db
● C) show db
● D) [Link]()
Answer: B) db

[Link] command is used to insert a single document into a MongoDB collection?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: B) [Link]()

[Link] method is used to insert multiple documents at once in MongoDB?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: A) [Link]()

[Link] MongoDB method retrieves all documents in a collection?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: C) [Link]()

[Link] read a single document matching a specific criterion from a collection, which
method would you use?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: A) [Link]()

[Link] operator is used to update specific fields in a document without replacing the
entire document?

● A) $replace
● B) $modify
● C) $set
● D) $update
Answer: C) $set

[Link] method is used to update one document that matches a specific query in
MongoDB?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: A) [Link]()

[Link] you want to update multiple documents matching a specific condition, which
method would you use?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: C) [Link]()

[Link] MongoDB method is used to delete a single document matching a query?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: A) [Link]()

[Link] delete all documents in a collection that match a specified condition, which method
is used?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: B) [Link]()

[Link] will happen if you use the [Link]() method without any
update operator like $set?
● A) MongoDB will throw an error.
● B) MongoDB will ignore the update operation.
● C) MongoDB will replace the entire document.
● D) MongoDB will update only the first field found.
Answer: C) MongoDB will replace the entire document.

[Link] method is used in MongoDB to retrieve documents from a collection that match
specific criteria?

● A) [Link]()
● B) [Link]()
● C) [Link]()
● D) [Link]()
Answer: C) [Link]()

[Link] operator is used in MongoDB to match documents where a field is equal to a


specific value?

● A) $eq
● B) $equals
● C) $match
● D) $find
Answer: A) $eq

[Link] would you write a query to find documents in a collection where the field "age" is
greater than 18?

● A) { age: { $gt: 18 } }
● B) { age: { $gte: 18 } }
● C) { age: { $lt: 18 } }
● D) { age: { $gt 18 } }
Answer: A) { age: { $gt: 18 } }

[Link] operator is used in MongoDB to check if a field’s value exists in an array of


specified values?

● A) $in
● B) $exists
● C) $match
● D) $array
Answer: A) $in
[Link] retrieve only specific fields from a document, which part of the find() method is
used?

● A) Sorting
● B) Projection
● C) Filtering
● D) Indexing
Answer: B) Projection

[Link] does the MongoDB query { status: { $ne: "complete" } } do?

● A) Finds documents where "status" is exactly "complete"


● B) Finds documents where "status" is not equal to "complete"
● C) Deletes documents where "status" is "complete"
● D) Updates documents to set "status" to "incomplete"
Answer: B) Finds documents where "status" is not equal to "complete"

[Link] operator would you use to combine multiple conditions in a MongoDB query
where all conditions must be met?

● A) $in
● B) $or
● C) $and
● D) $match
Answer: C) $and

[Link] does the query { "score": { $gte: 70, $lte: 90 } } find?

● A) Documents where "score" is less than 70


● B) Documents where "score" is greater than 90
● C) Documents where "score" is between 70 and 90, inclusive
● D) Documents where "score" equals 70 or 90
Answer: C) Documents where "score" is between 70 and 90, inclusive

[Link] query would find all documents where the "tags" field contains both "science"
and "technology"?

● A) { tags: { $in: ["science", "technology"] } }


● B) { tags: { $all: ["science", "technology"] } }
● C) { tags: { $contains: ["science", "technology"] } }
● D) { tags: { $eq: ["science", "technology"] } }
Answer: B) { tags: { $all: ["science", "technology"] } }

[Link] is the purpose of the $regex operator in MongoDB?


● A) To create indexes for efficient querying
● B) To allow for pattern matching in strings
● C) To enforce a specific schema
● D) To add new fields to a document
Answer: B) To allow for pattern matching in strings

[Link] is [Link] primarily used for?

● A) Front-end development
● B) Game development
● C) Back-end server-side development
● D) Database management
Answer: C) Back-end server-side development

[Link] language is [Link] built on?

● A) Python
● B) JavaScript
● C) Java
● D) Ruby
Answer: B) JavaScript

[Link] engine does [Link] use to execute JavaScript code?

● A) Chakra
● B) SpiderMonkey
● C) V8
● D) Rhino
Answer: C) V8

[Link] is known for which type of architecture?

● A) Synchronous and blocking


● B) Asynchronous and non-blocking
● C) Multi-threaded
● D) Procedural
Answer: B) Asynchronous and non-blocking

[Link] module in [Link] allows for managing HTTP requests and responses?

● A) fs
● B) events
● C) http
● D) path
Answer: C) http
[Link] is the purpose of npm (Node Package Manager) in [Link]?

● A) To manage system processes


● B) To compile JavaScript code
● C) To manage packages and dependencies
● D) To handle database connections
Answer: C) To manage packages and dependencies

[Link] of the following is a key feature of [Link] that makes it suitable for
data-intensive real-time applications?

● A) Multi-threading
● B) Event-driven architecture
● C) Synchronous code execution
● D) Strict typing
Answer: B) Event-driven architecture

[Link] does [Link] handle multiple connections at the same time?

● A) By using multiple threads


● B) By blocking I/O operations
● C) Through single-threaded, non-blocking I/O
● D) By spawning new processes for each connection
Answer: C) Through single-threaded, non-blocking I/O

[Link] of the following commands is used to initialize a new [Link] project and
create a [Link] file?

● A) node init
● B) npm start
● C) npm init
● D) node start
Answer: C) npm init

[Link] of the following features allows [Link] to handle high concurrency without
high memory consumption?

● A) Multi-threading
● B) Non-blocking I/O
● C) Synchronous processing
● D) Strongly typed variables
Answer: B) Non-blocking I/O

[Link] of the following is the correct way to check if [Link] is installed on your
system?
● A) node --version
● B) npm --install
● C) node install
● D) npm check
Answer: A) node --version

[Link] is npm primarily used for in [Link]?

● A) Managing [Link] versions


● B) Managing packages and dependencies
● C) Compiling JavaScript code
● D) Creating databases
Answer: B) Managing packages and dependencies

[Link] command would you use to install a package globally in [Link]?

● A) npm install package


● B) npm install -g package
● C) npm global install package
● D) npm add package
Answer: B) npm install -g package

[Link] file is created to manage project dependencies when you initialize a [Link]
project with npm init?

● A) node_modules.json
● B) [Link]
● C) [Link]
● D) [Link]
Answer: C) [Link]

[Link] command is used to install all dependencies listed in a [Link] file?

● A) npm install
● B) npm start
● C) npm init
● D) node install
Answer: A) npm install

[Link] remove an installed package from a project, which npm command would you use?

● A) npm delete package


● B) npm uninstall package
● C) npm remove --all
● D) npm clean package
Answer: B) npm uninstall package

[Link] command is used to create a [Link] file with default settings in


[Link]?

● A) npm init
● B) npm init -y
● C) npm create package
● D) npm new project
Answer: B) npm init -y

[Link] are globally installed npm packages stored by default?

● A) Inside the node_modules directory of each project


● B) In the global_modules folder
● C) In a global node_modules directory specific to npm
● D) In the npm_packages folder in each project
Answer: C) In a global node_modules directory specific to npm

[Link] does the caret (^) symbol mean in the version number of a dependency in
[Link]?

● A) Install the exact version specified


● B) Update to the latest version, regardless of compatibility
● C) Update to the latest minor or patch version, but not a major version
● D) Install only the beta version
Answer: C) Update to the latest minor or patch version, but not a major version

[Link] npm command would you use to update all project dependencies to their latest
versions?

● A) npm update
● B) npm upgrade --all
● C) npm install --latest
● D) npm update all
Answer: A) npm update

[Link] kind of process model does [Link] use?

● A) Multi-threaded
● B) Single-threaded
● C) Dual-threaded
● D) Threadless
Answer: B) Single-threaded

[Link] [Link], how is concurrency achieved despite using a single-threaded model?

● A) Using asynchronous, non-blocking I/O operations


● B) By using multiple threads internally
● C) Through synchronous processing
● D) Using only one connection at a time
Answer: A) Using asynchronous, non-blocking I/O operations

[Link] of the following allows [Link] to handle I/O operations without blocking the
main thread?

● A) Event loop
● B) Synchronous calls
● C) Call stack
● D) Data stream
Answer: A) Event loop

[Link] is the purpose of the event loop in [Link]?

● A) To execute synchronous code


● B) To handle blocking I/O only
● C) To manage and process asynchronous events
● D) To allocate memory for objects
Answer: C) To manage and process asynchronous events

[Link] module provides the functionality to work with child processes in [Link]?

● A) fs
● B) child_process
● C) events
● D) process
Answer: B) child_process

[Link] method in the child_process module allows the creation of a new [Link]
process?

● A) spawn()
● B) fork()
● C) exec()
● D) All of the above
Answer: D) All of the above

[Link] [Link] function is used to end the process and exit?

● A) exit()
● B) [Link]()
● C) quit()
● D) endProcess()
Answer: B) [Link]()

[Link] value does [Link](0) represent?

● A) Successful termination
● B) Unsuccessful termination
● C) Unknown status
● D) Termination with error code
Answer: A) Successful termination

[Link] does [Link] handle CPU-bound tasks effectively, given its single-threaded
nature?

● A) By utilizing the cluster module to spawn multiple processes


● B) By running CPU-bound tasks on the main thread
● C) Through synchronous I/O calls
● D) By blocking the event loop
Answer: A) By utilizing the cluster module to spawn multiple processes

[Link] does [Link]('exit', callback) do in [Link]?

● A) Restarts the process upon exit


● B) Runs a callback function before the process exits
● C) Halts the process immediately
● D) Sets the exit code for the process
Answer: B) Runs a callback function before the process exits

[Link] is a module in [Link]?

● A) A built-in database
● B) A reusable piece of code, either built-in or custom
● C) A collection of HTML files
● D) A global variable available across all scripts
Answer: B) A reusable piece of code, either built-in or custom

[Link] method is used to include a module in [Link]?


● A) import()
● B) include()
● C) require()
● D) use()
Answer: C) require()

[Link] module in [Link] is used for handling file operations?

● A) path
● B) fs
● C) os
● D) http
Answer: B) fs

[Link] does the exports object do in a [Link] module?

● A) Imports external modules


● B) Exports functions or variables from a module to be used in other files
● C) Deletes a module from memory
● D) Encodes data for transfer
Answer: B) Exports functions or variables from a module to be used in other files

[Link] of the following is a core module in [Link]?

● A) express
● B) mongodb
● C) http
● D) lodash
Answer: C) http

[Link] do you install a third-party module in [Link]?

● A) node install module_name


● B) npm install module_name
● C) install module_name
● D) module install module_name
Answer: B) npm install module_name

[Link] command is used to export a function in a module so that it can be used in


other files?

● A) [Link] = functionName
● B) [Link] = functionName
● C) [Link] = functionName
● D) export functionName
Answer: C) [Link] = functionName

[Link] is the purpose of the path module in [Link]?

● A) To create server connections


● B) To work with file and directory paths
● C) To interact with databases
● D) To manage environment variables
Answer: B) To work with file and directory paths

[Link] of the following is true about the require function in [Link]?

● A) It loads modules synchronously.


● B) It is only used for built-in modules.
● C) It cannot load local files.
● D) It is a method of the exports object.
Answer: A) It loads modules synchronously.

[Link] can you load a local module in [Link]?

● A) require('./module_name')
● B) require('module_name')
● C) import module_name
● D) include module_name
Answer: A) require('./module_name')

[Link] is asynchronous programming?

● A) A method of executing code line-by-line in order


● B) A technique that allows code to be executed without blocking other operations
● C) A way to make code run slower
● D) A type of debugging tool
Answer: B) A technique that allows code to be executed without blocking other
operations

[Link] of the following is a common benefit of asynchronous programming?

● A) It makes code harder to read


● B) It improves application responsiveness
● C) It increases memory usage
● D) It stops functions from running in parallel
Answer: B) It improves application responsiveness
[Link] JavaScript, which feature enables asynchronous behavior by executing code after
a specified delay?

● A) setInterval
● B) setTimeout
● C) clearTimeout
● D) executeLater
Answer: B) setTimeout

[Link] of the following is NOT a method for handling asynchronous operations in


JavaScript?

● A) Callbacks
● B) Promises
● C) Threads
● D) Async/await
Answer: C) Threads

[Link] is a callback function in asynchronous programming?

● A) A function that is immediately executed


● B) A function passed as an argument to another function, to be executed later
● C) A function that blocks other code from running
● D) A synchronous function that delays execution
Answer: B) A function passed as an argument to another function, to be executed later

[Link] is the purpose of a Promise in JavaScript?

● A) To handle synchronous operations


● B) To represent the eventual completion (or failure) of an asynchronous operation
● C) To delay code execution indefinitely
● D) To create multiple threads
Answer: B) To represent the eventual completion (or failure) of an asynchronous
operation

[Link] does the .then() method do in a Promise?

● A) It cancels the Promise


● B) It executes a callback function when the Promise is resolved
● C) It runs the Promise synchronously
● D) It re-throws any error in the Promise
Answer: B) It executes a callback function when the Promise is resolved

[Link] keyword is used to pause the execution of a function until a Promise is


resolved in JavaScript?
● A) await
● B) defer
● C) stop
● D) async
Answer: A) await

[Link] using async and await, what type of function must the await keyword be
used within?

● A) A standard function
● B) An async function
● C) An IIFE (Immediately Invoked Function Expression)
● D) A constructor function
Answer: B) An async function

[Link] statement about asynchronous programming is correct?

● A) Asynchronous code blocks further code execution.


● B) Asynchronous programming always makes code run faster.
● C) Asynchronous programming allows multiple tasks to be initiated without waiting for
other tasks to finish.
● D) Asynchronous programming does not allow callback functions.
Answer: C) Asynchronous programming allows multiple tasks to be initiated without
waiting for other tasks to finish.

You might also like