wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Node.js Fundamentals Assessment

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is Node.js primarily used for?

a)

Managing databases and data analytics.

b)

Creating desktop applications and mobile apps.

c)

Developing static websites and landing pages.

d)

Building scalable network applications and web servers.

2.

Which of the following is a core feature of Node.js?

a)

Static, synchronous request handling

b)

Synchronous, blocking I/O model

c)

Event-driven, non-blocking I/O model

d)

Single-threaded, multi-process architecture

3.

What command is used to initialize a new Node.js project?

a)

npm init

b)

npm install

c)

npm create

d)

npm start

4.

What file is created when you run 'npm init'?

a)

config.json

b)

package.json

c)

manifest.json

d)

dependencies.json

5.

Which method is used to create a server in Node.js?

a)

http.createServer

b)

http.newServer

c)

http.startServer

d)

http.makeServer

6.

What is the purpose of the 'require' function in Node.js?

a)

To handle HTTP requests and responses in a Node.js server.

b)

To define global variables for the entire application.

c)

To execute asynchronous code in a Node.js application.

d)

To import modules and include external libraries or files in a Node.js application.

7.

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

a)

UDP

b)

TCP

c)

HTTP

d)

FTP

8.

What does the 'package.json' file contain?

a)

The 'package.json' file contains user credentials and passwords.

b)

The 'package.json' file contains a list of all files in the project directory.

c)

The 'package.json' file contains metadata about a Node.js project, including name, version, dependencies, and scripts.

d)

The 'package.json' file contains only the project's license information.

9.

How do you install a package using npm?

a)

npm install

b)

npm get

c)

npm fetch

d)

npm add

10.

What is the default port for HTTP servers in Node.js?

a)

8080

b)

3000

c)

5000

d)

4000

11.

Which command is used to install a package globally?

a)

npm add -g

b)

npm install --global

c)

npm install -g

d)

npm install

12.

What is the purpose of the 'dependencies' section in 'package.json'?

a)

To specify the packages required for the project to run.

b)

To list the project's contributors and authors.

c)

To define the project's license and permissions.

d)

To outline the project's build scripts and commands.

13.

How can you update a package using npm?

a)

npm remove

b)

npm install

c)

npm list

d)

npm update

14.

What is the command to uninstall a package?

a)

npm erase

b)

npm uninstall or pip uninstall

c)

npm remove

d)

pip delete

15.

What does the 'scripts' section in 'package.json' allow you to do?

a)

Manage dependencies for your project.

b)

Run scripts in a browser environment.

c)

Create new npm packages easily.

d)

Define custom commands for automation in npm.

16.

Which method is used to listen for incoming connections on a socket?

a)

bind

b)

accept

c)

connect

d)

listen

17.

What is the purpose of the 'exports' object in a Node.js module?

a)

The 'exports' object allows a Node.js module to expose its functionality to other modules.

b)

The 'exports' object manages the internal state of a Node.js application.

c)

The 'exports' object is used to define private variables in a module.

d)

The 'exports' object is responsible for handling HTTP requests in a module.

18.

How do you create a readable stream in Node.js?

a)

const http = require('http'); const readableStream = http.get('http://example.com');

b)

const fs = require('fs'); const readableStream = fs.readFile('path/to/file.txt');

c)

const fs = require('fs'); const writableStream = fs.createWriteStream('path/to/file.txt');

d)

const fs = require('fs'); const readableStream = fs.createReadStream('path/to/file.txt');

19.

What is the command to check the version of npm?

a)

npm -v

b)

npm check-version

c)

npm version

d)

npm --version

20.

What does the 'devDependencies' section in 'package.json' signify?

a)

The 'devDependencies' section signifies runtime dependencies.

b)

The 'devDependencies' section signifies optional dependencies.

c)

The 'devDependencies' section signifies global dependencies.

d)

The 'devDependencies' section signifies development-only dependencies.