Online Exam Quiz

questionQuestion  1 to 30

Which method is used to handle errors in Express.js middleware?

  • app.error()
  • app.catchError()
  • app.catchError()
  • app.use()
Mark for review

Which of the following is true about Express.js?

  • It is a monolithic framework.
  • It provides built-in support for database management.
  • It is a minimal and flexible framework.
  • It is only suitable for front-end development
Mark for review

What is the default port for an Express.js application?

  • 5000
  • 3000
  • 80
  • 8080
Mark for review

How do you access query string parameters in Express.js?

  • req.params
  • req.query
  • req.route
  • req.body
Mark for review

Which method is used to set response headers in Express.js?

  • res.set()
  • res.headers()
  • res.sendHeaders()
  • res.writeHead()
Mark for review

Which method is used to handle all HTTP methods for a single route?

  • app.every()
  • app.methods()
  • app.any()
  • app.all()
Mark for review

Which HTTP method is NOT supported by Express.js?

  • GET
  • TRACE
  • DELETE
  • POST
Mark for review

How do you install Express.js?

  • fetch express
  • install express
  • npm install express
  • get express
Mark for review

How do you create a sub-application in Express.js?

  • Using express.SubApp()
  • Using express.Application()
  • Using express.Router()
  • Using express.SubRouter()
Mark for review

How do you define a route with a parameter in Express.js?

  • app.get('/user/
  • app.get('/user/id')
  • app.get('/user?=id')
  • app.get('/user.id')
Mark for review

How do you access route parameters in Express.js?

  • Using the req.query object
  • Using the req.params object
  • Using the req.body object
  • Using the req.headers object
Mark for review

What does req represent in Express.js?

  • Render
  • Request
  • Route
  • Response
Mark for review

Which method is used to start an Express.js server?

  • express.start()
  • server.run()
  • app.listen()
  • app.start
Mark for review

How do you remove a route in Express.js?

  • app.removeRoute()
  • app.dropRoute()
  • app.deleteRoute()
  • There's no built-in method to remove routes
Mark for review

How do you send a status code in Express.js?

  • res.status()
  • res.sendCode()
  • res.code()
  • res.httpStatus()
Mark for review

Which template engine is commonly used with Express.js?

  • Pug
  • Handlebars
  • EJS
  • All of the above
Mark for review

How do you handle 404 errors in Express.js?

  • app.error(404)
  • app.missing(404)
  • app.route(404)
  • app.use((req, res) => { res.status(404).send('Not Found'); })
Mark for review

How do you enable CORS in Express.js?

  • Using enable-cors middleware
  • Using cors middleware
  • Using cross-origin middleware
  • Using express-cors middleware
Mark for review

Which of the following is a middleware in Express.js?

  • css-loader
  • body-parser
  • node-fetch
  • html-parser
Mark for review

How do you handle HTTPS in Express.js?

  • Using express.secure()
  • Using express.https()
  • Using https.createServer()
  • Using app.https()
Mark for review

Which method is used to define middleware functions in Express.js?

  • app.use()
  • app.get()
  • app.post()
  • app.useMiddleware()
Mark for review

Which of the following is true about route parameters in Express.js?

  • They are optional in route definitions.
  • They are accessed using the query object.
  • They are enclosed in curly braces {} in route
  • They are used only for POST requests
Mark for review

What does res.redirect() do in Express.js?

  • Sends a response with the specified status code
  • Sends a response with the specified content
  • Redirects the request to another URL
  • Terminates the request without sending any response
Mark for review

How do you define environment variables in Express.js?

  • Using environment module
  • Using config module
  • Using dotenv module
  • Using env module
Mark for review

How do you set a cookie in Express.js?

  • res.cookie()
  • res.createCookie()
  • res.setCookie()
  • res.addCookie()
Mark for review

What is the purpose of the app.locals object in Express.js?

  • To store local variables available in templates
  • To handle HTTP requests
  • To define middleware functions
  • To render views
Mark for review

Which module is used to create a server in Express.js?

  • http
  • express
  • fs
  • path
Mark for review

Which method is used to delete a resource in RESTful API design?

  • GET
  • POST
  • PUT
  • DELETE
Mark for review

What is the purpose of the app.route() method in Express.js?

  • To define route handlers for different HTTP methods on a single route path
  • To define middleware functions
  • To serve static files
  • To render views
Mark for review

Which HTTP method is used to update a resource in RESTful API design?

  • GET
  • POST
  • PUT
  • DELETE
Mark for review

blinkerOnline

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • Answered
  • Not Answered
  • Marked for Review