Online Exam Quiz

questionQuestion  1 to 30

How do you include middleware only for certain routes in Express.js?

  • By specifying middleware in the route handler function
  • By using the app.use() method before defining the routes
  • By using the app.route() method
  • By using the app.use() method with a path parameter
Mark for review

Which method is used to handle HTTP PUT requests in Express.js?

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

What is the purpose of the express.static() middleware?

  • To serve static files such as images, CSS, and JavaScript
  • To handle HTTP GET requests
  • To render views
  • To parse request bodies
Mark for review

What is the purpose of the express.urlencoded() middleware?

  • To parse JSON data in request bodies
  • To parse URL-encoded data in request bodies
  • To handle authentication
  • To render views
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 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 number for an Express.js server?

  • 3000
  • 8080
  • 8080
  • 5000
Mark for review

How do you redirect a request in Express.js?

  • res.relocate()
  • res.sendFile()
  • res.route()
  • res.redirect()
Mark for review

How do you reload an Express.js server without restarting it manually?

  • Using nodemon
  • Using reloader
  • Using express-reload
  • Using auto-restart
Mark for review

What does res.send() 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

Which method is used to parse JSON bodies in Express.js?

  • express.urlencoded()
  • express.body()
  • express.parse()
  • express.json()
Mark for review

How do you serve static files from a directory named "public"?

  • app.serve('public')
  • app.static('public')
  • app.use('public')
  • app.use(express.static('public'))
Mark for review

Which of the following is true about Express.js middleware?

  • Middleware can only be used for authentication.
  • Middleware functions have access to the request and response objects.
  • Middleware functions cannot be chained.
  • Middleware can only be defined globally
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

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

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

  • 5000
  • 3000
  • 80
  • 8080
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 method is used to render a view in Express.js?

  • res.render()
  • res.send()
  • res.json()
  • res.sendFile()
Mark for review

What is the purpose of the express.json() middleware?

  • To parse JSON data in request bodies
  • To serve static files
  • To handle HTTP GET requests
  • To render views
Mark for review

How do you define a dynamic route in Express.js?

  • By using regular expressions
  • By appending a colon : before the parameter name in the route definition
  • By specifying the route parameter in the request body
  • By using the req.params object
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 access query string parameters in Express.js?

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

Which method is used to send a file as a response?

  • res.file()
  • res.serveFile()
  • res.sendFile()
  • res.send()
Mark for review

What does req represent in Express.js?

  • Render
  • Request
  • Route
  • Response
Mark for review

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

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

How do you log requests in Express.js?

  • Using morgan middleware
  • Using pino middleware
  • Using bunyan middleware
  • Using winston middleware
Mark for review

How do you listen for server events in Express.js?

  • Using express.events
  • Using app.events
  • Using Node.js's built-in events module
  • Using express.listeners
Mark for review

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

  • GET
  • POST
  • PUT
  • DELETE
Mark for review

How do you end the response process?

  • res.end()
  • res.terminate()
  • res.finish()
  • res.close()
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

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