Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Node Js Quizz

Total questions: 20

Worksheet time: 11mins

Name
Class
Date
1.

What is the primary role of the event loop in Node.js?

a)

Handling HTTP requests

b)

Managing asynchronous operations

c)

Synchronizing database queries

d)

Controlling the DOM in the browser

2.

Which of the following is a characteristic of readable streams in Node.js?

a)

They are bidirectional.

b)

They are always in flowing mode.

c)

They emit 'finish' event when data is written.

d)

They cannot be piped.

3.

In Express.js, what is the purpose of the next function in middleware?

a)

It terminates the middleware execution.

b)

It passes control to the next middleware in the stack.

c)

It triggers a route handler.

d)

It sends a response to the client.

4.

Which keyword is used to import modules in CommonJS (Node.js) syntax?

a)

import

b)

use

c)

require

d)

include

5.

In Node.js, what is the purpose of the 'domain' module?

a)

It handles errors in asynchronous operations.

b)

It manages the application's global state.

c)

It isolates error handling for specific parts of the application.

d)

It sets the default error handling behavior.

6.

Scaling and Performance

a)

Distributing tasks to worker threads.

b)

Running multiple instances of the application on different servers.

c)

Optimizing the performance of individual functions.

d)

Managing database connections.

7.

How can you mitigate common security vulnerabilities in a Node.js application?

a)

Regularly update Node.js modules.

b)

Disable error logging.

c)

Use weak passwords for authentication.

d)

Store sensitive information directly in the source code.

8.

Which testing framework is commonly used for Node.js applications?

a)

Mocha

b)

Jest

c)

Jasmine

d)

All of the above

9.

What is the purpose of JWT (JSON Web Tokens) in user authentication?

a)

Storing user passwords securely.

b)

Encoding user information in a compact format.

c)

Verifying the integrity of HTTP requests.

d)

Encrypting communication between the client and server.

10.

Which protocol is commonly used with WebSockets in Node.js?

a)

HTTP

b)

TCP

c)

UDP

d)

SMTP

11.

How can you implement caching in a Node.js application?

a)

Using the localStorage object

b)

Utilizing the cache module

c)

Implementing in-memory caching with tools like Redis

d)

Adding cache headers to HTTP responses

12.

What is CORS, and how can you handle it in a Node.js application?

a)

Cross-Origin Resource Sharing; handled automatically by Node.js

b)

A security feature that prevents cross-site scripting

c)

A mechanism to control which domains can make requests to your server

d)

A Node.js module for handling cross-domain requests

13.

What is GraphQL, and how does it differ from traditional REST APIs?

a)

A query language for APIs with a focus on flexibility and efficiency

b)

A Node.js package for rendering dynamic HTML pages

c)

A security protocol for securing API endpoints

d)

A framework for building real-time applications

14.

How can Docker be beneficial for Node.js applications?

a)

It automatically optimizes Node.js code for better performance

b)

It helps in packaging applications and their dependencies into containers

c)

It replaces the need for package managers like npm

d)

It provides a built-in testing environment for Node.js

15.

What is serverless computing, and how does Node.js fit into serverless architectures?

a)

Serverless computing is a model where applications are run without servers; Node.js is not suitable for serverless

b)

Serverless computing allows running functions without managing servers; Node.js functions can be used in serverless environments

c)

Serverless is a term used for applications without any client-server interaction

d)

Node.js is a serverless framework for building applications without traditional servers

16.

How can Prometheus be used for monitoring a Node.js application?

a)

It is a Node.js module for logging events

b)

Prometheus is not applicable to Node.js applications

c)

Prometheus collects and stores metrics from Node.js applications

d)

It is a built-in feature of the Node.js runtime for tracking errors

17.

What is the purpose of the "payload" in a JSON Web Token (JWT) used for authentication?

a)

It contains the user's password

b)

It is used for digital signature verification

c)

It stores claims about the user

d)

It determines the token's expiration time

18.

How does Express.js facilitate the creation of RESTful APIs in Node.js?

a)

It automatically generates API documentation

b)

It provides routing and middleware features for handling HTTP requests

c)

It enforces strict REST principles, limiting flexibility

d)

Express.js is not suitable for building RESTful APIs

19.

Which library is commonly used for WebSocket communication in Node.js?

b)

WebSocket.js

c)

WebSockets-NPM

d)

RealtimeIO

20.

What techniques can be used to optimize the performance of a Node.js application?

a)

Minifying JavaScript code and using a Content Delivery Network (CDN)

b)

Increasing the number of blocking synchronous operations

c)

Ignoring code profiling and monitoring

d)

Using a single-threaded approach without clustering