WorksheetsNode.js Fundamentals Assessment
Total questions: 20
Worksheet time: 10mins
What is Node.js primarily used for?
Managing databases and data analytics.
Creating desktop applications and mobile apps.
Developing static websites and landing pages.
Building scalable network applications and web servers.
Which of the following is a core feature of Node.js?
Static, synchronous request handling
Synchronous, blocking I/O model
Event-driven, non-blocking I/O model
Single-threaded, multi-process architecture
What command is used to initialize a new Node.js project?
npm init
npm install
npm create
npm start
What file is created when you run 'npm init'?
config.json
package.json
manifest.json
dependencies.json
Which method is used to create a server in Node.js?
http.createServer
http.newServer
http.startServer
http.makeServer
What is the purpose of the 'require' function in Node.js?
To handle HTTP requests and responses in a Node.js server.
To define global variables for the entire application.
To execute asynchronous code in a Node.js application.
To import modules and include external libraries or files in a Node.js application.
Which protocol is commonly used with sockets in Node.js?
UDP
TCP
HTTP
FTP
What does the 'package.json' file contain?
The 'package.json' file contains user credentials and passwords.
The 'package.json' file contains a list of all files in the project directory.
The 'package.json' file contains metadata about a Node.js project, including name, version, dependencies, and scripts.
The 'package.json' file contains only the project's license information.
How do you install a package using npm?
npm install
npm get
npm fetch
npm add
What is the default port for HTTP servers in Node.js?
8080
3000
5000
4000
Which command is used to install a package globally?
npm add -g
npm install --global
npm install -g
npm install
What is the purpose of the 'dependencies' section in 'package.json'?
To specify the packages required for the project to run.
To list the project's contributors and authors.
To define the project's license and permissions.
To outline the project's build scripts and commands.
How can you update a package using npm?
npm remove
npm install
npm list
npm update
What is the command to uninstall a package?
npm erase
npm uninstall
npm remove
pip delete
What does the 'scripts' section in 'package.json' allow you to do?
Manage dependencies for your project.
Run scripts in a browser environment.
Create new npm packages easily.
Define custom commands for automation in npm.
Which method is used to listen for incoming connections on a socket?
bind
accept
connect
listen
What is the purpose of the 'exports' object in a Node.js module?
The 'exports' object allows a Node.js module to expose its functionality to other modules.
The 'exports' object manages the internal state of a Node.js application.
The 'exports' object is used to define private variables in a module.
The 'exports' object is responsible for handling HTTP requests in a module.
How do you create a readable stream in Node.js?
const http = require('http'); const readableStream = http.get('http://example.com');
const fs = require('fs'); const readableStream = fs.readFile('path/to/file.txt');
const fs = require('fs'); const writableStream = fs.createWriteStream('path/to/file.txt');
const fs = require('fs'); const readableStream = fs.createReadStream('path/to/file.txt');
What is the command to check the version of npm?
npm -v
npm check-version
npm version
npm --version
What does the 'devDependencies' section in 'package.json' signify?
The 'devDependencies' section signifies runtime dependencies.
The 'devDependencies' section signifies optional dependencies.
The 'devDependencies' section signifies global dependencies.
The 'devDependencies' section signifies development-only dependencies.
