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

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

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 can you pass parameters in an Express.js route?

  • Using the query string
  • Using the request body
  • Using route parameters
  • All of the above
Mark for review

What is Express.js?

  • A front-end JavaScript framework
  • A back-end JavaScript framework
  • A database management system
  • A testing framework
Mark for review

What is next() used for in middleware functions?

  • To terminate the request-response cycle
  • To render a view
  • To send a response
  • To pass control to the next middleware
Mark for review

How do you install Express.js in a Node.js project?

  • Using npm install express
  • Using npm install express-generator
  • Using npm install -g express
  • Using npm install express --save
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

How do you set a view engine in Express.js?

  • app.set('view engine', 'pug')
  • app.render('view engine', 'pug')
  • app.engine('view', 'pug')
  • app.use('view engine', 'pug')
Mark for review

How do you create a modular route in Express.js?

  • Using express.RouteHandler()
  • Using express.Router()
  • Using express.Module()
  • Using express.Route()
Mark for review

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

  • req.params
  • req.query
  • req.route
  • req.body
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

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

Which middleware is commonly used for parsing incoming request bodies?

  • express.static()
  • express.json()
  • express.urlencoded()
  • express.cookieParser
Mark for review

How do you start a server in Express.js?

  • app.listen()
  • app.run()
  • app.start()
  • app.begin()
Mark for review

How do you monitor performance in an Express.js application?

  • Using express-status-monitor middleware
  • Using perf-monitor middleware
  • Using express-perf middleware
  • Using app-monitor middleware
Mark for review

Which module is used to create an Express.js application?

  • http
  • express
  • fs
  • path
Mark for review

How do you handle JSON Web Tokens (JWT) in Express.js?

  • Using jsonwebtoken middleware
  • Using express-jwt middleware
  • Using express-token middleware
  • Using jwt-express middleware
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

How do you access route parameters in Express.js?

  • req.route
  • req.body
  • req.query
  • req.params
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

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

  • GET
  • POST
  • PUT
  • DELETE
Mark for review

How do you set up a static file server in Express.js?

  • Using the app.static() method
  • Using the express.static() middleware
  • By configuring the server settings
  • There's no built-in way to serve static files in Express.js
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

Which middleware is used to parse URL-encoded bodies?

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

How do you handle multipart/form-data in Express.js?

  • Using form-data middleware
  • Using multer middleware
  • Using body-parser middleware
  • Using express-body middleware
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 can you access query parameters in Express.js?

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

What is the purpose of the next() function in Express.js middleware?

  • To send the response
  • To invoke the next middleware function
  • To terminate the request
  • To render the view
Mark for review

Which template engine is commonly used with Express.js?

  • Pug
  • Handlebars
  • EJS
  • All of the above
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