0% found this document useful (0 votes)
9 views5 pages

MCQ Key Point

The document outlines key points related to Full Stack Development using Node.js and MongoDB, including features of Node.js such as its non-blocking I/O model and the use of NPM for package management. It also covers essential MongoDB operations, document structure, and methods for querying and manipulating data. Additionally, it highlights the integration of Node.js with Express.js for handling HTTP requests and middleware functionalities.

Uploaded by

subroto7432
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)
9 views5 pages

MCQ Key Point

The document outlines key points related to Full Stack Development using Node.js and MongoDB, including features of Node.js such as its non-blocking I/O model and the use of NPM for package management. It also covers essential MongoDB operations, document structure, and methods for querying and manipulating data. Additionally, it highlights the integration of Node.js with Express.js for handling HTTP requests and middleware functionalities.

Uploaded by

subroto7432
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
You are on page 1/ 5

FULL STACK DEVELOPMENT-I

BCA 2023
KEY POINTS TO REMEMBER

1. Node.js is built on the V8 JavaScript engine.


2. Node.js features single-threaded, non-blocking I/O.
3. Node.js allows JavaScript to run on the server.
4. The package manager for Node.js is NPM.
5. Node.js packages are available on the NPM platform.
6. Node.js is commonly used for real-time applications.
7. Node.js is widely used to build RESTful APIs.
8. Traditional web servers use a multi-threaded model.
9. Node.js is non-blocking, while traditional models are blocking.
10. Node.js servers are more efficient for multiple I/O operations.
11. Node.js can be downloaded from nodejs.org.
12. To verify Node.js installation, use node --version.
13. Use Brew to install Node.js on MacOS.
14. NPM is installed with Node.js to manage packages.
15. Node.js modules are stored in the node_modules folder.
16. The node -v command displays the Node.js version.
17. console.log('Hello World') outputs "Hello World".
18. Node.js executes JavaScript on the server-side.
19. The event loop in Node.js enables asynchronous processing.
20. Node.js handles multiple connections via a single-threaded event loop.
21. An advantage of Node.js is its non-blocking asynchronous I/O.
22. Node.js handles requests using an event-driven, non-blocking I/O model.
23. Traditional web servers handle HTTP requests using a thread pool.
24. Node.js handles HTTP requests through non-blocking I/O.
25. Node.js is more efficient due to its non-blocking event loop.
26. The function of require() in importing modules is to: Load dependencies
27. The file that represents project metadata in Node.js is: package.json
28. The statement NOT true about buffers in Node.js is: They require import
29. The command used to initialize a Node.js project is: npm init
30. The npm update command is used to: Update packages
31. The command to check the version of an installed NPM package is: npm view [package-name] version
32. The command to show only outdated package names is: npm outdated --depth 0
33. The module type when using require('http') is: Core module
34. In Node.js, import() is used for ES modules only
35. Core modules are built-in, local modules are created by the user
36. Commands to install packages locally and globally are: npm install [package-name] and npm install -g
[package-name]
37. Running npm install installs local packages listed in package.json
38. Built-in modules in Node.js include: http, events, fs, path, url
39. npm is a tool for managing Node.js modules and dependencies
40. The method to import the HTTP core module is: require('http')
41. To export multiple functions from a local module: All of the above (module.exports, exports object, etc.)
42. package-lock.json locks installed versions of dependencies
43. To view installed packages in a project, use: npm list
44. If require() fails, check module existence, installation, and name – All of the above
45. HTTP requests in Node.js are handled using: http.createServer()
46. fs.readFileSync() is synchronous, fs.readFile() is asynchronous
47. To convert a buffer to a string: Buffer.toString()
48. The HTTP module allows creation of servers to handle HTTP requests
49. To create a basic web server in Node.js: Use http.createServer()
50. Asynchronous file read is done using: fs.readFile()
51. fs.readFileSync() throws an error if the file does not exist.
52. The correct order to initialize and run an HTTP server is createServer(), request(), and listen().
53. Writing to an invalid file path using fs.writeFileSync() causes an error.
54. The fs module provides both synchronous and asynchronous file operations.
55. Attempting to overwrite a read-only file throws a permission error.
56. path.parse() breaks a file path into parts like root, dir, base, ext, and name.
57. The fs module is used to work with the file system in Node.js.
58. CRUD operations (Create, Read, Update, Delete) are supported by the fs module.
59. res.write() sends a response to the client in an HTTP server.
60. The http.createServer() callback receives request and response objects.
61. Common HTTP methods include GET, POST, PUT, DELETE, PATCH, and OPTIONS.
62. fs.unlink() is used to delete a file in Node.js.
63. fs.appendFile() appends data to the end of a file.
64. Use fs.mkdirSync() or fs.mkdir() to create a directory.
65. fs.rename() is used to rename or move a file.
66. HTTP status code 500 indicates an internal server error.
67. res.json() is used to send JSON data in a response.
68. The Content-Type header specifies the format of the response body.
69. The callback in fs.readFile() receives an error (if any) and the file data.
70. The encoding option in file reading defines the character encoding (e.g., utf8).
71. The Accept header specifies the media types the client can accept.
72. Static files are the same for all users and do not change dynamically.
73. In a POST request, data is sent in the body of the request.
74. GET method retrieves data from the server without making changes.
75. Query parameters in a URL follow ? and are in key-value format.
76. Logging HTTP requests can be done using fs.writeFile(), fs.appendFile(), or writable streams.
77. const app = express() Initialize Express app properly using the express() function, not new.
78. app.use(middlewareFunction)Use app.use() to apply middleware globally across all routes.
79. app.use((req, res) => { res.status(404).send('Not Found'); }) Use app.use() at the end to define a custom
404 handler.
80. req.query Access query parameters from the URL like ?name=John using req.query.
81. req.params Access URL route parameters like /user/:id using req.params.
82. next(); Call next() in middleware to pass control to the next handler.
83. express.json()Parse incoming JSON payloads with express.json() middleware.
84. event.once('eventName', callback) Register an event listener that runs only once using once().
85. app.get('/route', middlewareFunction, handlerFunction)Apply middleware to a specific route by passing it
before the handler.
86. app.get('/', callback)Handle GET requests with app.get().
87. app.post('/submit', callback) Handle form submissions (usually POST requests) with app.post()
88. app.use((req, res, next) => { next(); })Create a custom middleware using the (req, res, next) signature.
89. node inspect app.js Run Node.js in debug mode with the inspect command.
90. Use it to execute the next statement The it command (in debugger) runs the next JavaScript statement.
91. watch()Monitor variable values during debugging with watch().
92. A function that handles incoming HTTP requests Middleware processes HTTP requests and responses.
93. app.get(), app.post(), app.put(), app.delete() Standard methods for defining route handlers in Express.
94. Handles POST requests and sends a response with status 201​
app.post() handles POST, res.status(201).send() sends a 201 status.
95. on(), off(), emit(), addListener()EventEmitter methods to manage and trigger events.
96. A loop that waits for events and handles them asynchronously Event loop manages asynchronous
operations in Node.js.
97. Global middleware, then route-specific middleware Middleware is executed in the order it's defined:
global first, then route-level.
98. It renders HTML templates and sends them to the client as responses res.render() is used with templating
engines (e.g., EJS, Pug).
99. app.use(function(req, res, next) { /* middleware logic */ }) Correct syntax to define and register
middleware.
100. (err, req, res, next)Error-handling middleware must have four arguments in this order.
101. It can be used to debug both synchronous and asynchronous code Node.js debugger supports both sync
and async operations.
102. Node.js can be used to debug both synchronous and asynchronous code – It can be used to debug both
synchronous and asynchronous code.
103. MongoDB is a Document-based NoSQL Database – Document-based NoSQL Database.
104. Key feature of MongoDB is Flexible schema design – Flexible schema design.
105. Basic unit of storage in MongoDB is Document – Document.
106. MongoDB documents are typically recognized by the ObjectId – By the ObjectId.
107. Primary data format used in MongoDB is JSON – JSON.
108. MongoDB operation used for creating a new record is insert() – insert().
109. Correct syntax for reading documents in MongoDB is db.collection.find() – db.collection.find().
110. Package commonly used to connect MongoDB with Node.js is mongoose – mongoose.
111. find() returns multiple documents; findOne() returns only one document – find() returns multiple
documents; findOne() returns only one document.
112. The _id field in a MongoDB document uniquely identifies each document in a collection – It uniquely
identifies each document in a collection.
113. Correct method to send a file from the server to the client is res.sendFile(path.join(__dirname, 'file.txt')) –
res.sendFile(path.join(__dirname, 'file.txt')).
114. Correct method to query MongoDB for users over age 18 is db.users.find({age: {$gt: 18}}) –
db.users.find({age: {$gt: 18}}).
115. MongoDB query to find documents with 'JavaScript' in tags array is db.collection.find({tags: {$in:
['JavaScript']}}) – db.collection.find({tags: {$in: ['JavaScript']}}).
116. Method to count users in users collection is db.users.countDocuments() – db.users.countDocuments().
117. Appropriate way to connect Node.js app to MongoDB is mongoose.connect('mongodb://localhost/mydb')
– mongoose.connect('mongodb://localhost/mydb').
118. mongoose.model() defines the structure of a MongoDB document – It defines the structure of a
MongoDB document.
119. Bulk insert operation in MongoDB is done using insertMany() – db.users.insertMany([{...}, {...}]).
120. Query to retrieve the first matching document is db.users.findOne({}) – db.users.findOne({}).
121. Method to delete a single document with email '[email protected]' is – db.users.deleteOne({email:
'[email protected]'}).
122. Confirm MongoDB connection before running Node.js app – All of these.
123. Syntax to mount middleware on all routes in Express.js – app.use(middleware).
124. Result of db.collection.updateOne({name: "Bob"}, {$set: {age: 25}}) – It will update the age of the
document where name is "Bob".
125. Effect of db.collection.find({}).limit(10) – It will limit the number of documents returned to 10.

126. Node.js can be used to debug both synchronous and asynchronous code – It can be used to debug both
synchronous and asynchronous code.

127. MongoDB is a Document-based NoSQL Database – Document-based NoSQL Database.

128. Key feature of MongoDB is Flexible schema design – Flexible schema design.

129. Basic unit of storage in MongoDB is Document – Document.

130. MongoDB documents are typically recognized by the ObjectId – By the ObjectId.

131. Primary data format used in MongoDB is JSON – JSON.

132. MongoDB operation used for creating a new record is insert() – insert().

133. Correct syntax for reading documents in MongoDB is db.collection.find() – db.collection.find().

134. Package commonly used to connect MongoDB with Node.js is mongoose – mongoose.

135. find() returns multiple documents; findOne() returns only one document – find() returns multiple documents;
findOne() returns only one document.

136. The _id field in a MongoDB document uniquely identifies each document in a collection – It uniquely
identifies each document in a collection.

137. Correct method to send a file from the server to the client is res.sendFile(path.join(__dirname, 'file.txt')) –
res.sendFile(path.join(__dirname, 'file.txt')).

138. Correct method to query MongoDB for users over age 18 is db.users.find({age: {$gt: 18}}) –
db.users.find({age: {$gt: 18}}).

139. MongoDB query to find documents with 'JavaScript' in tags array is db.collection.find({tags: {$in:
['JavaScript']}}) – db.collection.find({tags: {$in: ['JavaScript']}}).

140. Method to count users in users collection is db.users.countDocuments() – db.users.countDocuments().

141. Appropriate way to connect Node.js app to MongoDB is mongoose.connect('mongodb://localhost/mydb') –


mongoose.connect('mongodb://localhost/mydb').

142. mongoose.model() defines the structure of a MongoDB document – It defines the structure of a MongoDB
document.

143. Bulk insert operation in MongoDB is done using insertMany() – db.users.insertMany([{...}, {...}]).

144. Query to retrieve the first matching document is db.users.findOne({}) – db.users.findOne({}).


145. Method to delete a single document with email '[email protected]' is – db.users.deleteOne({email:
'[email protected]'}).

146. Confirm MongoDB connection before running Node.js app – All of these.

147. Syntax to mount middleware on all routes in Express.js – app.use(middleware).

148. Result of db.collection.updateOne({name: "Bob"}, {$set: {age: 25}}) – It will update the age of the
document where name is "Bob".

149. Effect of db.collection.find({}).limit(10) – It will limit the number of documents returned to 10.

150. MongoDB query to return only name and age fields – db.collection.find({}, {name: 1, age: 1}).

You might also like