Online Exam Quiz

questionQuestion  1 to 30

Which method is used to define a route handler in Express.js?

  • app.handle()
  • app.route()
  • app.get()
  • app.use()
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

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

How do you end the response process?

  • res.end()
  • res.terminate()
  • res.finish()
  • res.close()
Mark for review

How do you create a custom middleware in Express.js?

  • By defining a function with (req, res, next)
  • By defining a function with (res, req, next)
  • By defining a function with (req, res)
  • By defining a function with (req, res, done)
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

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

  • To handle HTTP GET requests
  • To define middleware functions
  • To serve static files
  • To render views
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

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

  • app.every()
  • app.methods()
  • app.any()
  • app.all()
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

Which middleware is used for authentication and authorization in Express.js?

  • passport
  • bcrypt
  • jsonwebtoken
  • All of the above
Mark for review

How do you rate limit requests in Express.js?

  • Using express-ratelimit middleware
  • Using rate-limiter middleware
  • Using express-rate-limit middleware
  • Using limit-requests middleware
Mark for review

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

  • app.get()
  • app.post()
  • app.patch()
  • 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

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

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

  • GET
  • POST
  • PUT
  • DELETE
Mark for review

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

  • app.delete()
  • app.del()
  • app.remove()
  • app.use()
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 handle HTTPS in Express.js?

  • Using express.secure()
  • Using express.https()
  • Using https.createServer()
  • Using app.https()
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

What is the purpose of the express.Router() method in Express.js?

  • To define middleware functions
  • To create modular route handlers
  • To handle static files
  • To render views
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

What is middleware in Express.js?

  • Software used to connect Express with a database
  • Functions that have access to the request and response objects
  • A template engine used to generate HTML
  • A method for handling HTTP requests
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 define environment variables in Express.js?

  • Using environment module
  • Using config module
  • Using dotenv module
  • Using env module
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

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

What does res represent in Express.js?

  • Request
  • Render
  • Route
  • Response
Mark for review

How do you handle request timeouts in Express.js?

  • Using request-timeout middleware
  • Using timeout middleware
  • Using express-timeout middleware
  • Using req-timeout middleware
Mark for review

How do you redirect a request in Express.js?

  • res.relocate()
  • res.sendFile()
  • res.route()
  • res.redirect()
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