1. What is Node.js?
a) A front-end JavaScript framework
b) A back-end JavaScript runtime environment
c) A database system
d) A CSS preprocessor
2. Which package manager is commonly used with Node.js?
a) npm
b) yarn
c) bower
d) both a and b
3. What is the purpose of the `package.json` file?
a) To store project dependencies
b) To define server configurations
c) To write server-side JavaScript code
d) To create database connections
4. What is the Node.js Event Loop?
a) A mechanism for handling asynchronous operations
b) A way to store data in memory
c) A method for creating HTTP servers
d) A tool for debugging Node.js applications
5. What is the I/O Cycle in Node.js?
a) The process of reading and writing files
b) The sequence of events that occur when handling a request
c) The way Node.js manages memory
d) The method for creating modules
6. How do you create a Node.js module?
a) By using the `module.exports` object
b) By creating a separate JavaScript file
c) By using the `require()` function
d) All of the above
7. Which HTTP method is used to retrieve data from a server?
a) GET
b) POST
c) PUT
d) DELETE
8. How do you create an HTTP server in Node.js?
a) Using the `http` module
b) Using the `fs` module
c) Using the `path` module
d) Using the `url` module
9. What is routing in Node.js?
a) The process of handling different URL requests
b) The way data is transmitted over the network
c) The method for creating databases
d) The process of debugging server-side code
10. Which module can be used to create a simple web server in Node.js?
a) `express`
b) `http`
c) `fs`
d) `path`
11. What type of database is MongoDB?
a) Relational database
b) NoSQL database
c) SQL database
d) In-memory database
12. What is a document in MongoDB?
a) A table in a database
b) A row in a table
c) A JSON-like structure
d) A query language
13. How do you install MongoDB?
a) Using a package manager like `apt` or `brew`
b) Downloading and installing from the official website
c) Using Docker
d) All of the above
14. What is MongoDB Compass?
a) A graphical user interface for MongoDB
b) A command-line interface for MongoDB
c) A programming language for MongoDB
d) A data visualization tool
15. What is the Mongo Shell?
a) A command-line interface for MongoDB
b) A graphical user interface for MongoDB
c) A programming language for MongoDB
d) A data visualization tool
16. What is a collection in MongoDB?
a) A group of related documents
b) A table in a database
c) A row in a table
d) A query language
17. Which command is used to insert a document into a collection?
a) `find()`
b) `insertOne()`
c) `update()`
d) `deleteOne()`
18. Which command is used to retrieve documents from a collection?
a) `find()`
b) `insertOne()`
c) `update()`
d) `deleteOne()`
19. What is a query in MongoDB?
a) A way to filter and retrieve data from a collection
b) A way to create new collections
c) A way to update documents
d) A way to delete documents
20. What is the purpose of the `_id` field in MongoDB?
a) To uniquely identify each document
b) To store the creation date of the document
c) To store the last modified date of the document
d) To store user-defined metadata
21. What is the purpose of the `fs` module in Node.js?
a) To work with the file system
b) To create HTTP servers
c) To handle network requests
d) To work with the database
22. What is the purpose of the `path` module in Node.js?
a) To work with file and directory paths
b) To create HTTP servers
c) To handle network requests
d) To work with the database
23. What is the purpose of the `url` module in Node.js?
a) To parse and format URLs
b) To create HTTP servers
c) To handle network requests
d) To work with the database
24. What is a middleware function in Node.js?
a) A function that handles requests and responses in a chain
b) A function that creates HTTP servers
c) A function that works with the file system
d) A function that handles database connections
25. Which Node.js framework is popular for building web applications?
a) Express.js
b) React.js
c) Angular
d) Vue.js
26. What is the purpose of the `request` object in an HTTP server?
a) Contains information about the incoming request
b) Contains information about the outgoing response
c) Contains information about the server
d) Contains information about the database
27. What is the purpose of the `response` object in an HTTP server?
a) Contains information about the incoming request
b) Contains information about the outgoing response
c) Contains information about the server
d) Contains information about the database
28. What is the purpose of the `status` method of the `response` object?
a) To set the HTTP status code of the response
b) To set the content type of the response
c) To send data to the client
d) To end the response
29. What is the purpose of the `end()` method of the `response` object?
a) To set the HTTP status code of the response
b) To set the content type of the response
c) To send data to the client and end the response
d) To end the response without sending data
30. What is the purpose of the `listen()` method of the `http.createServer()`
function?
a) To start the HTTP server
b) To stop the HTTP server
c) To handle incoming requests
d) To send responses to clients
31. What is the purpose of the `find()` method in MongoDB?
a) To retrieve documents from a collection
b) To insert documents into a collection
c) To update documents in a collection
d) To delete documents from a collection
32. What is the purpose of the `findOne()` method in MongoDB?
a) To retrieve the first document that matches the query
b) To retrieve all documents that match the query
c) To insert a single document into a collection
d) To update a single document in a collection
33. What is the purpose of the `insertOne()` method in MongoDB?
a) To insert a single document into a collection
b) To insert multiple documents into a collection
c) To retrieve documents from a collection
d) To update documents in a collection
34. What is the purpose of the `updateOne()` method in MongoDB?
a) To update a single document in a collection
b) To update multiple documents in a collection
c) To retrieve documents from a collection
35. What is the purpose of the deleteOne() method in MongoDB?
o a) To delete a single document from a collection
o b) To delete multiple documents from a collection
o c) To retrieve documents from a collection
o d) To update documents in a collection`
36. What is the purpose of the deleteMany() method in MongoDB?
o a) To delete a single document from a collection
o b) To delete multiple documents from a collection
o c) To retrieve documents from a collection
o d) To update documents in a collection
37. What is the purpose of the createIndex() method in MongoDB?
o a) To delete a single document from a collection
o b) To delete multiple documents from a collection
o c) To create indexes
o d) To update documents in a collection
38. What is the purpose of the group() method in MongoDB?
o a) To group documents by a specified field
o b) To perform aggregation operations on data
o c) To create a new collection
o d) To drop a collection
39. What is the purpose of the aggregate() method in MongoDB?
o a) To group documents by a specified field
o b) To perform aggregation operations on data
o c) To create a new collection
o d) To drop a collection
40. What is the purpose of the createCollection() method in MongoDB?
o a) To group documents by a specified field
o b) To perform aggregation operations on data
o c) To create a new collection
o d) To drop a collection
41. What is the purpose of the dropCollection() method in MongoDB?
o a) To group documents by a specified field
o b) To perform aggregation operations on data
o c) To create a new collection
o d) To drop a collection
42. What is the purpose of the use() method in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To show all databases
43. What is the purpose of the db.dropDatabase() method in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To show all databases
44. What is the purpose of the show dbs() method in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To show all databases
45. What is the purpose of the show collections() method in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To show all collections in a database
46. What is the purpose of the exit() method in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To exit the Mongo Shell
47. What is the purpose of the db command in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To show all databases
48. What is the purpose of the help() method in MongoDB?
o a) To drop a database
o b) To create a database
o c) To use a specific database
o d) To display the help information
Answers
1. b) A back-end JavaScript runtime environment
2. d) both a and b
3. a) To store project dependencies
4. a) A mechanism for handling asynchronous operations
5. b) The sequence of events that occur when handling a request
6. d) All of the above
7. a) GET
8. a) Using the http module
9. a) The process of handling different URL requests
10. b) http
11. b) NoSQL database
12. c) A JSON-like structure
13. d) All of the above
14. a) A graphical user interface for MongoDB
15. a) A command-line interface for MongoDB
16. a) A group of related documents
17. b) insertOne()
18. a) find()
19. a) A way to filter and retrieve data from a collection
20. a) To uniquely identify each document
21. a) To work with the file system
22. a) To work with file and directory paths
23. a) To parse and format URLs
24. a) A function that handles requests and responses in a chain
25. a) Express.js
26. a) Contains information about the incoming request
27. b) Contains information about the outgoing response
28. a) To set the HTTP status code of the response
29. c) To send data to the client and end the response
30. a) To start the HTTP server
31. a) To retrieve documents from a collection
32. a) To retrieve the first document that matches the query
33. a) To insert a single document into a collection
34. a) To update a single document in a collection
35. b) To update multiple documents in a collection
36. a) To delete a single document from a collection
37. b) To delete multiple documents from a collection
38. c) To create indexes
39. a) To group documents by a specified field
40. b) To perform aggregation operations on data
41. c) To create a new collection
42. a) To drop a collection
43. b) To create a database
44. a) To drop a database
45. c) To use a specific database
46. a) To show all databases
47. b) To show all collections in a database
48. a) To exit the Mongo Shell
49. c) To display the current database
50. a) To display the help information