Online Exam Quiz

questionQuestion  1 to 30

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

  • GET
  • POST
  • PUT
  • DELETE
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 remove a route in Express.js?

  • app.removeRoute()
  • app.dropRoute()
  • app.deleteRoute()
  • There's no built-in method to remove routes
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 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

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

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

Which command is used to install Express.js globally?

  • npm install express
  • npm install -g express-generator
  • npm install -g express
  • npm install -g express.js
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 log requests in Express.js?

  • Using morgan middleware
  • Using pino middleware
  • Using bunyan middleware
  • Using winston middleware
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 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 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

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

  • 5000
  • 3000
  • 80
  • 8080
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

What is the use of res.json() in Express.js?

  • To render a view
  • To send a file
  • To redirect to another URL
  • To send a JSON response
Mark for review

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

  • To handle all HTTP requests
  • To serve static files
  • To define middleware functions
  • To render views
Mark for review

How do you access route parameters in Express.js?

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

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

  • app.error()
  • app.catchError()
  • app.catchError()
  • app.use()
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 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 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

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

  • express.urlencoded()
  • express.body()
  • express.parse()
  • express.json()
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

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 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

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

How do you install Express.js?

  • fetch express
  • install express
  • npm install express
  • get express
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.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

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