Express.js, or simply Express, is a back end web application framework for building RESTful APIs with Node.js, released as free and open-source software under the MIT License.
Express.js MCQs: This section contains multiple-choice questions and answers on the various topics of Express.js. Practice these MCQs to test and enhance your skills on Express.js.
List of Express.js MCQs
1. Express.js is a ____ framework?
- Node.js
- JavaScript
- React.js
- Angular.js
Answer: A) Node.js
Explanation:
Express.js is a Node.js framework.
2. Express.js is written in which of the following language?
- Python
- Node.js
- JavaScript
- C++
Answer: C) JavaScript
Explanation:
Express.js is written in JavaScript.
3. Among Express.js and Django which is faster?
- Django
- Express.js
Answer: B) Express.js
Explanation:
Express is significantly quicker than Django.
4. Which of the following command is used to install Express in the myapp directory?
- $ npm install express
- $ npm install –express
- $ npm install –express.js
Answer: A) $ npm install express
Explanation:
$ npm install express command is used to install Express in the myapp directory.
5. What does the following do, res.send()?
- This method specifies what to execute when a get request at the specified route is made
- This function binds and waits for connections on the provided host and port
- This method accepts an object as input and returns it to the requesting client
Answer: C) This method accepts an object as input and returns it to the requesting client.
Explanation:
res.send(), this method accepts an object as an input and returns it to the requesting client.
6. What does the following do, app.listen(port, [host], [backlog], [callback]])?
- This method specifies what to execute when a get request at the specified route is made
- This function binds and waits for connections on the provided host and port
- This method accepts an object as input and returns it to the requesting client
Answer: B) This function binds and waits for connections on the provided host and port.
Explanation:
app.listen(port, [host], [backlog], [callback]]), this function binds and waits for connections on the provided host and port.
7. Which of the following method can be used with any of the HTTP verbs: get, set, put, or delete?
- app.get(route, callback)
- res.send()
- app.listen(port, [host], [backlog], [callback]])
- app.method(path, handler)
Answer: D) app.method(path, handler)
Explanation:
app.method(path, handler) method can be used with any of the HTTP verbs: get, set, put, or delete.
8. In app.method(path, handler) method, which parameter is a call back function that is executed when a matching request type is detected on the appropriate route?
- Path
- Handler
Answer: B) Handler
Explanation:
Handler is a callback function that is executed when a matching request type is detected on the appropriate route.
9. In app.method(path, handler) method, which parameter, is the route at which the request will run?
- Path
- Handler
Answer: A) Path
Explanation:
Path is the route at which the request will run.
10. Express provides a unique method ____ that handles all forms of HTTP methods at a specific route using the same function?
- Whole
- App
- All
Answer: C) All
Explanation:
Express provides a unique method, “all” that handles all forms of HTTP methods at a specific route using the same function.
11. Which of the following HTTP method, are used to transmit a limited amount of data, as the data is included in the header?
- GET
- POST
- PUT
- DELETE
Answer: A) GET
Explanation:
GET requests are used to transmit a limited amount of data, as the data is included in the header.
12. ____ requests are used to transmit a large amount of data, as the data is included in the body of the request?
- GET
- POST
- PUT
- DELETE
Answer: B) POST
Explanation:
POST requests are used to transmit a large amount of data, as the data is included in the body of the request.
13. ____ is a templating engine for Express?
- Oil
- Master
- Body parser
- Pug
Answer: D) Pug
Explanation:
Pug is a templating engine for Express.
14. To use Pug with Express do we need to install it first?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, to use Pug first you need to install it.
15. How do you write comments in Pug?
- //Hello
- **hello
- /*hello
Answer: A) //Hello
Explanation:
Pug uses the same syntax as JavaScript(//) for creating comments.
16. ____ files are those that clients download directly from the server?
- Dynamic
- Component
- Static
Answer: C) Static
Explanation:
Static files are those that clients download directly from the server.
17. ____ are little pieces of information transmitted from a website and kept in the user’s web browser when the user visits that page.?
- Session
- Cookies
- Forms
Answer: B) Cookies
Explanation:
Cookies are little pieces of information transmitted from a website and kept in the user’s web browser when the user visits that page.
18. Which of the following do you need to install to acquire cookie abilities in Express.js?
- cookie-parser
- Cookie—
- Parser_cookie
- Use_cookies
Answer: A) cookie-parser
Explanation:
cookie-parser is installed to acquire cookie abilities in Express.js.
19. ____ functions are those that interact with the request and response objects (req, res) during the request-response cycle?
- Data binding
- Routing
- Middleware
Answer: C) Middleware
Explanation:
Middleware functions are those that interact with the request and response objects (req, res) during the request-response cycle.
20. ____ is the process of constructing the application’s skeletal structure?
- Binding
- Scaffolding
- Application
- Dynamic Routing
Answer: B) Scaffolding
Explanation:
Scaffolding is the process of constructing the application’s skeletal structure.
21. Which of the following command will install the Scaffold in express.js?
- npm install express-scaffold
- npm install expressscaffolding
- npm install express__scaffold
- npm install expressjs-scaffold
Answer: A) npm install express-scaffold
Explanation:
npm install express-scaffold is the correct command which will install the Scaffold in express.js.
22. ____ is the process of comparing the credentials presented to those stored in a database?
- Authentication
- Authorization
Answer: B) Authorization
Explanation:
Authentication is the process of comparing the credentials presented to those stored in a database.
23. What is REST?
- Redirect state transfer
- Represent state transfer
- Representational Transfer State
Answer: C) Representational Transfer State
Explanation:
Representational Transfer State is the full form of REST.
24. The ____ allows you to use static template files in your application?
- View
- View engine
- Modals
- Template engine
Answer: D) Template engine
Explanation:
The template engine allows you to use static template files in your application.
25. ____ is used to handle errors in Express?
- Routes
- Middleware
- Router
- Controller
Answer: B) Middleware
Explanation:
Middleware is used to handle errors in Express.
26. Debug is ____ by default in express.js?
- On
- Off
Answer: B) Off
Explanation:
Debug is off by default.
27. Which of the following middleware is used for binding the app object with the help of the app.use() method?
- Application-level-middleware
- Router-level-middleware
- User level middleware
- Built-in-level middleware
Answer: A) Application-level-middleware
Explanation:
Application-level middleware is used for binding the app object with the help of the app.use() method.
28. Which of the following router for binding with a specific Express.Router instance()?
- Application-level-middleware
- Router-level-middleware
- User-level middleware
- Built-in-level middleware
Answer: B) Router-level-middleware
Explanation:
Router-level-middleware for binding with a specific Express.Router instance().
29. What is CORS in express.js?
- Conception origination reserve sharing
- Cross-origin reserve sharing
- Cross-origin resource sharing
Answer: C) Cross-origin resource sharing
Explanation:
CORS stands for Cross-origin resource sharing.
30. Which of the following arguments are available in an Express JS route handler function?
- req – the request object
- res – the response object
- next
- All of the above
Answer: D) All of the above
Explanation:
Following arguments are available in an Express JS route handler function:
- req – the request object
- res – the response object
- next
31. Routing is provided by default in ____ but not provided in ____?
- Node.js and express.js
- Express.js and node.js
- Node.js and react.js
Answer: B) Express.js and node.js
Explanation:
Routing is provided by default in Express.js but not provided in Node.js.
32. ____ is Super-fast, all-natural JSON logger express.js?
- Pino logger
- Morgan
- Minor
- Debug logger
Answer: A) Pino logger
Explanation:
Pino is Super-fast, all-natural JSON logger express.js.
33. The ____ object is used to handle data sent to the server through string or JSON object?
- Response
- Request
Answer: B) Request
Explanation:
The request object is used to handle data sent to the server through a string or JSON object.
34. The data is returned to the client via the ____ object?
- Response
- Request
Answer: A) Response
Explanation:
The data is returned to the client via the response object.
35. Sessions are saved on the ____ side?
- Server
- Client
Answer: A) Server
Explanation:
Sessions are saved on the server side.
36. Cookies are saved on the ____ side?
- Server
- Client
Answer: B) Client
Explanation:
Cookies are saved on the client side.
37. Which of the following are third-party middleware?
- Body-parser
- Cookie-parser
- Mongoose
- Sequelize
- All of the above
Answer: E) All of the above
Explanation:
Following are the third-party middleware:
- Body-parser
- Cookie-parser
- Mongoose
- Sequelize
38. HTTP is stateless or stateful?
- Stateless
- Stateful
Answer: A) Stateless
Explanation:
HTTP is stateless.
39. Does Express.js supports both RDBMS and NoSQL DB?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, Express.js supports both RDBMS and NoSQL DB.
40. Which of the following companies are using Express.js?
- Accenture
- Stack
- Kevin
- All of the above
Answer: E) All of the above
Explanation:
Following companies are using express.js:
- Accenture
- Stack
- Kevin
41. Which of the following are the alternatives of Express.js?
- Ember JS
- BackboneJS
- Vue JS
- Knockout JS
- All of the above
Answer: E) All of the above
Explanation:
Following are the alternatives of express.js:
- Ember JS
- BackboneJS
- Vue JS
- Knockout JS