ARDSOFT IT SERVICES
MERN Stack- Node-Express-Mongodb This test include question of Node Express and MongoDB NameEmail How can you access query parameters in a URL using Express.js? req.params req.query req.queryParams req.urlParams Which command creates a package.json file? npm start node init npm create npm init What is the purpose of the next() function in Express.js middleware? To end the request-response cycle To skip the current middleware function To send a response to the client To pass control to the next middleware function What will be the output of the following code snippet when a request is made to the /calculate endpoint with the query parameters num1=5 and num2=10? app.get('/calculate', (req, res) => { const num1 = parseInt(req.query.num1); const num2 = parseInt(req.query.num2); const sum = num1 + num2; res.send({ sum: sum }); }); { sum: NaN } Error: num1 or num2 is not a number { sum: '510' } { sum: 15 } Which HTTP method is used to retrieve data? GET POST DELETE PUT Which statement creates a Promise? new Promise() new Async() create Promise() Promise.create() What is the purpose of the app.use() method in Express.js? To use a middleware function To set a custom port To render a view To define a route Which method converts an object into JSON string? JSON.stringify() JSON.parse() toJSON() convertJSON() Which package is commonly used to connect MongoDB with Node.js? mongoose mongo-node mongodb-connect dbconnect Which HTTP status indicates successful creation? 404 201 204 200 Which keyword is used to handle errors? error try…catch catchError handle Which status code means “Not Found”? 404 200 301 500 In MongoDB, which command deletes an entire collection? drop() removeCollection() deleteCollection() clear() In Express.js, which object is used to send a response to the client? response res send request How can you set a custom port for your Express.js application? app.port = 3000; app.use(3000); app.set('port', 3000); app.listen(3000); Which command installs MongoDB driver for Node.js? node install mongodb npm install mongoose-db npm install mongodb npm install mongo Which command shows all collections in a MongoDB database? db.collections() show collections show tables list collections Which method removes the last element from an array? pop() delete() remove() shift() MongoDB stores data in which format? Documents Arrays Tables Rows Which function in Express is used to start the server? app.server() app.run() app.listen() app.start() Which method updates a document in MongoDB? edit() updateOne() setOne() modifyOne() How do you define a route in Express.js? app.get('/route', function(req, res) { // route handling logic }); app.use('/route', function(req, res) { // route handling logic }); app.set('/route', function(req, res) { // route handling logic }); app.route('/route').get(function(req, res) { // route handling logic }); What will be the output of the following code snippet? print(typeof(NaN)); String Number None of the above Object How can you access form data in a POST request using Express.js? req.headers req.query req.body req.params Which method is used to insert a document in MongoDB? insertOne() create() addOne() push() What is the main purpose of package.json in a Node.js project? Run server automatically Store application code Manage project dependencies and metadata Store database schema How can you create a route in Express.js to handle a DELETE request to the /delete-user/:userId endpoint and delete the user with the specified ID? app.route('/delete-user/:id') .delete((req, res) => { const id = req.params.id; // Delete the user with the specified id }); app.delete('/delete-user/:userId', (req, res) => { const userId = req.params.userId; // Delete the user with the specified userId }); app.delete('/delete/:id', (req, res) => { const id = req.params.id; // Delete the resource with the specified id }); app.delete('/:userId', (req, res) => { const userId = req.params.userId; // Delete the user with the specified userId }); What will be the output of the following code snippet? const obj1 = {first: 20, second: 30, first: 50}; console.log(obj1); Syntax Error {first: 50, second: 30} {first: 20, second: 30} {first: 20, second: 30; first: 50} Which function delays execution for specified milliseconds? delay() pause() wait() setTimeout() Which module is used to create a router in Express? router.create() express.route() express.Router() express.createRouter() 0%
MERN Stack- Node-Express-Mongodb
This test include question of Node Express and MongoDB
How can you access query parameters in a URL using Express.js?
Which command creates a package.json file?
What is the purpose of the next() function in Express.js middleware?
What will be the output of the following code snippet when a request is made to the /calculate endpoint with the query parameters num1=5 and num2=10?
app.get('/calculate', (req, res) => { const num1 = parseInt(req.query.num1); const num2 = parseInt(req.query.num2); const sum = num1 + num2; res.send({ sum: sum }); });
Which HTTP method is used to retrieve data?
Which statement creates a Promise?
What is the purpose of the app.use() method in Express.js?
Which method converts an object into JSON string?
Which package is commonly used to connect MongoDB with Node.js?
Which HTTP status indicates successful creation?
Which keyword is used to handle errors?
Which status code means “Not Found”?
In MongoDB, which command deletes an entire collection?
In Express.js, which object is used to send a response to the client?
How can you set a custom port for your Express.js application?
Which command installs MongoDB driver for Node.js?
Which command shows all collections in a MongoDB database?
Which method removes the last element from an array?
MongoDB stores data in which format?
Which function in Express is used to start the server?
Which method updates a document in MongoDB?
How do you define a route in Express.js?
What will be the output of the following code snippet? print(typeof(NaN));
How can you access form data in a POST request using Express.js?
Which method is used to insert a document in MongoDB?
What is the main purpose of package.json in a Node.js project?
How can you create a route in Express.js to handle a DELETE request to the /delete-user/:userId endpoint and delete the user with the specified ID?
What will be the output of the following code snippet?
const obj1 = {first: 20, second: 30, first: 50};
console.log(obj1);
Which function delays execution for specified milliseconds?
Which module is used to create a router in Express?
Software service provider delivering custom development, integration, and support to help businesses build, launch, and scale reliable digital products.