wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Node-JS-Test

Total questions: 131

Worksheet time: 1hrs 5mins

Name
Class
Date
1.

Which programming language is the Google V8 Engine designed for?

a)

Java

b)

JavaScript

c)

Python

d)

R

2.

Which JavaScript library is used to create Desktop apps in Node.js?

a)

React.js

b)

React Native

c)

Electron.js

d)

Express.js

3.

Which JavaScript library is used to create Progressive Web apps in Node.js?

a)

React.js

b)

React Native

c)

Electron.js

d)

Express.js

4.

Node.js is a Closed-source Technology. True or False?

a)

True

b)

False

5.

JavaScript used which of the following I/O model?

a)

Non-Blocking I/O Model

b)

Blocking I/O Model

c)

None.

6.

Node.js is ____________Threaded language

a)

Single

b)

Multi

c)

Dual

7.

Which of the following command is used to run a node.js program?

a)

node run main.js

b)

node start main.js

c)

start main.js

d)

node main.js

8.

Which of the following code will print "Hello" on the output screen?

a)

print("Hello");

b)

console.log(Hello);

c)

console.log("Hello");

d)

printf("%s","Hello");

9.

________ is a back end web application framework for Node.js, it is fast, unopinionated and minimalist framework.

a)

Emotional.js

b)

Express.js

c)

Nodemon

d)

Doraemon

10.

What is the right syntax for importing a module?

a)

require()

b)

function()

c)

import()

d)

module.import()

11.

What JavaScript Engine is used by Google Chrome?

a)

Y8

b)

Adobe Flash Player

c)

Friv

d)

V8

12.

Which of the module used for Buffer

a)

node module

b)

No module required for Buffer

c)

npm i buffer

d)

node main.js

13.

Which of the following core module is used for file system operations in Node.js?

a)
  • A) http

b)
  • B) fs

c)
  • C) path

  • D) querystring

d)
  • D) querystring

14.

Which of the following is NOT a core module in Node.js?

a)
  • A) http

b)
  • B) fs

c)
  • C) express

d)
  • D) os

15.

To listen for connections, what function would you use?

a)

app.listen

b)

app.serve

c)

app.connect

d)

app.start

16.

Which of the following methods is used to create a server in Node.js?

a)
  • A) createServer()

b)
  • B) startServer()

c)
  • C) initServer()

d)
  • D) runServer()

17.

What is the purpose of the npm command in Node.js?

a)
  • A) To manage global Node.js installations

b)
  • B) To create a new Node.js project

c)
  • C) To install and manage packages/modules for a Node.js project

d)
  • D) To execute JavaScript code directly from the command line

18.

Which is the most famous backend technology which is based on JavaScript?

a)

Springboot

b)

Flask

c)
Node.js
d)

Django

19.
What is Node.js?
a)
A front-end framework
b)
A back-end JavaScript runtime environment
c)
A database management system
d)
A browser extension
20.
What is the primary use of Node.js?
a)
To build interactive user interfaces
b)
To develop mobile applications
c)
To write server-side applications
d)
To create graphics and animations
21.
Which of the following is true about Node.js?
a)
It's a compiled language
b)
It's single-threaded and asynchronous
c)
It's primarily used for desktop applications
d)
It's not suitable for web development
22.
Which of the following modules is a built-in module in Node.js?
a)
express
b)
path
c)
request
d)
mongoose
23.
What is the Node.js 'event loop' responsible for?
a)
Processing incoming HTTP requests
b)
Running JavaScript code asynchronously
c)
Managing database connections
d)
Handling server security
24.
Which HTTP status code is typically used for a successful HTTP GET request?
a)
200 (OK)
b)
404 (Not Found)
c)
500 (Internal Server Error)
d)
401 (Unauthorized)
25.
What does 'npm' stand for?
a)
Node Package Manager
b)
New Programming Module
c)
Node Project Manager
d)
Node Program Manager
26.

________ is a back end web application framework for Node.js, it is fast, unopinionated and minimalist framework.

a)

Emotional.js

b)

Express.js

c)

Nodemon

d)

Doraemon

27.

What module provides utilities for working with file and directory paths?

a)

OS Module

b)

Path Module

c)

FS Module

d)

HTTP Module

28.

________ are the blocks of encapsulated code that communicates with an external application on the basis of their related functionality.

a)

Application

b)

Code

c)

Dependencies

d)

Modules

29.

What module provides information about the computer's operating system?

a)

OS Module

b)

Path Module

c)

FS Module

d)

HTTP Module

30.

What is the right syntax for importing a module?

a)

require()

b)

function()

c)

import()

d)

module.import()

31.

_____is used to raise the event.

a)

myEmitter.emitter()

b)

myEmtter.emit()

c)

myEmitter.event()

d)

myEmitter.emitEvent()

32.

Which of the following is correct syntax?

a)

fs.writeFile("filename", data, callback);

b)

fs.writeFile(data ,"filename", callback);

c)

fs.writeFile(callback, data, "filename");

d)

None

33.

Which of the following is correct?

a)

fs.unlink(path)

b)

fs.unlinkSync(path)

c)

fs.delete(path)

d)

fs.deleteSync(path)

34.

To check if a file exists, use

a)

fs.accessFile()

b)

fs.access()

c)

Both

d)

None

35.

Which of the following asynchronously append data to a file

a)

fs.append(path, data[, options])

b)

fs.appendFile(path, data[, options])

c)

fs.append(path, data[, options], callback)

d)

fs.appendFile(path, data[, options], callback)

36.

What is the advantage of using node.js?

a)

Great concurrency

b)

Generally fast

c)

It provides an easy way to build scalable network programs

d)

All of these

37.

Which of the following areas, Node.js is not advised to be used?

a)

Single Page Applications

b)

JSON APIs based Applications

c)

CPU intensive applications

d)

Data Intensive Realtime Applications (DIRT)

38.

3.       Which of the following is an IF statement in JavaScript?

a)

if i = 5

b)

if i = 5 then

c)

if (i == 5)

d)

All of these

39.

What will be the output of following code snippet?

JSON.stringify({ message: "Hello World"});

a)

{message:Hello World}{message:Hello World}

b)

{‘message’:’Hello World’}

c)

{"message":"Hello World"}

d)

None

40.

What is a runtime environment?

a)

.An environment in which a program or application is executed

b)

An environment where files can be saved

c)

A Virtual Machine where other operating systems can run

41.

Can we execute JavaScript code outside a web browser?

a)

Yes sure

b)

No, because it’s a programming language used to develop Front-end and Back-end applications on the browser

c)

Not sure

42.

JavaScript used which of the following I/O model?

a)

Non-Blocking I/O Model

b)

Blocking I/O Model

c)

None.

43.

Who made node.js?

a)

Hampton Catlin

b)

Ryan Dahl

c)

Isaac Z. Schlueter

d)

GitHub

44.

When did Ryan Dahl authored Node.js?

a)

2007

b)

2008

c)

2009

d)

2010

45.

What will be the output

var num = 10

console.log(num + 10)

a)

20

b)

83

c)

None of these

d)

Hello!

46.

JSON was a native construct of which language?

a)

PHP

b)

Java

c)

Ruby On Rails

d)

Javascript

47.

How can you see all the dependencies for a Node.js app?

a)

All the dependencies are listed down in the package.json file

b)

By executing "npm i" and capturing the dependencies list

c)

You can't have dependencies in a Node.js app

d)

All the dependencies are listed down in the package-dependencies.json file

48.

Which is the correct syntax for Arrow Function?

a)

->

b)

<--!

c)

=>

d)

function arrow()

49.

________ are the blocks of encapsulated code that communicates with an external application on the basis of their related functionality.

a)

Application

b)

Code

c)

Dependencies

d)

Modules

50.

In web development, what is a framework?

a)

A tool we use to design GUIs (Graphical user interfaces)

b)

A cloud tool used to host websites

c)

A place for developers to collaborate and work asynchronously

d)

A software designed to support the development of web applications including web services, web resources, and web APIs

51.

What will be the output

var num = 10

console.log(num + 10)

a)

20

b)

83

c)

None of these

d)

Hello!

52.

To connect Mongo dB Database from NodeJS which middleware we require?

a)

Body-parser

b)

Mongoose

c)

Express

d)

None of these

53.

What are core features of Express framework?

a)

Allows to set up middle-ware to respond to HTTP Requests

b)

Defines a routing table which can works as per HTTP Method and URL

c)

Dynamically render HTML Pages

d)

All of the above

54.

Which of the following is a NoSQL Database Type ?

a)

SQL

b)

Document databases

c)

JSON

d)

All of the mentioned

55.

What is Callback

a)

It is a technique in which a function is executed after executing the calling function

b)

Only calls a specific function

c)

Node of these

56.

NodeJS uses an event-driven, non-blocking I/O model

a)

True

b)

False

57.
What is Express.js?
a)
A JavaScript runtime environment
b)
A front-end framework
c)
A back-end web application framework
d)
A package manager for Node.js
58.
Express.js is based on which architectural pattern?
a)
MVC (Model-View-Controller)
b)
ORM (Object-Relational Mapping)
c)
MVP (Model-View-Presenter)
d)
MVVM (Model-View-ViewModel)
59.
Which HTTP request method is used to create a new resource in RESTful API using Express.js?
a)
GET
b)
POST
c)
PUT
d)
DELETE
60.
What is a middleware in Express.js?
a)
A function that handles routes
b)
A way to store data in a database
c)
A method for user authentication
d)
A user interface component
61.
In Express.js, what does the `app.use()` method do?
a)
Create a new route
b)
Define a route handler
c)
Mount a middleware function
d)
Send a response to the client
62.
In Express.js, how do you handle dynamic route parameters in a URL?
a)
Using query parameters
b)
Using the 'body' property
c)
Using route parameters like '/:id'
d)
Using the 'headers' property
63.
What is the purpose of the 'next' function in Express.js middleware?
a)
It sends a response to the client
b)
It terminates the server
c)
It passes control to the next middleware function
d)
It retrieves user data from a database
64.

What HTTP method is typically used for retrieving data from a server?

a)

GET

b)

DELETE

c)

PUT

d)

POST

65.

How can you handle errors in a REST API client in Node.js?

a)

Use try-catch blocks, error handling middleware, and return proper HTTP status codes.

b)

Return random HTTP status codes for errors

c)

Ignore errors and continue with the API calls

d)

Use Python instead of Node.js for error handling

66.

What is the purpose of authentication in REST API clients?

a)

To allow unauthorized access to resources

b)

To decrease API security

c)

To increase server load

d)

To verify the identity of the client making requests and ensure only authorized users can access the API resources.

67.

How can you pass request parameters in a REST API client using axios?

a)

{ method: 'GET', url: 'https://api.example.com/data', params: { key1: 'value1', key2: 'value2' } }

b)

method: 'POST', url: 'https://api.example.com/data'

c)

params: {key1: 'value1', key2: 'value2'}

d)

headers: {Authorization: 'Bearer token'}

68.

What is the role of response handling in a REST API client?

a)

Response handling in a REST API client is not important for error checking

b)

Response handling in a REST API client involves sending data to the server

c)

The role of response handling in a REST API client is to process the data received from the server, including parsing the response, checking for errors, and extracting relevant information for further use.

d)

Response handling in a REST API client is only necessary for POST requests

69.

Which library is commonly used for making HTTP requests in Node.js?

a)

superagent

b)

fetch

c)

axios

d)

requestify

70.

What is the purpose of node-fetch in a REST API client?

a)

To format data in a REST API client

b)

To handle user authentication in a REST API client

c)

To make HTTP requests in a REST API client.

d)

To generate random data in a REST API client

71.

Which HTTP method is used for updating data on a server?

a)

POST

b)

PUT

c)

DELETE

d)

GET

72.

How can you implement error handling in a node-fetch based REST API client?

a)

Use if-else statements to handle errors in fetch requests

b)

Ignore errors and proceed with the API client operations

c)

Implement a custom error handling module separate from the fetch requests

d)

Use try-catch blocks to catch errors during fetch requests and handle them accordingly.

73.

Why is authentication important in REST API clients?

a)

Authentication can slow down the client-server communication

b)

Authentication is not important in REST API clients

c)

Authentication helps in verifying the identity of the client making the request and protects against unauthorized access.

d)

Authentication increases the risk of security breaches

74.

What are query parameters and how are they used in REST API clients?

a)

Query parameters are used to define the HTTP method in REST API clients

b)

Query parameters are added to the URL before the base endpoint in REST API clients

c)

Query parameters are added to the request body in REST API clients

d)

Query parameters are added to the URL after a '?' symbol, with each parameter separated by '&'. For example, in the URL 'https://api.example.com/users?status=active&page=1', 'status' and 'page' are query parameters.

75.

How can you access the response data in an axios request?

a)

response.content

b)

response.data

c)

response.json

d)

response.text

76.

What are the advantages of using axios for making HTTP requests?

a)

Axios does not support JSON data transformation

b)

Axios provides a simple and powerful way to make HTTP requests with additional features like interceptors, automatic JSON data transformation, and support for both browser and Node.js environments.

c)

Axios can only be used in Node.js environment

d)

Axios is slower than other HTTP request libraries

77.

What are the disadvantages of using node-fetch for HTTP requests?

a)

Node-fetch is not compatible with all operating systems

b)

Node-fetch lacks support for streaming responses, handling cookies, and automatic response body parsing.

c)

Node-fetch has built-in security vulnerabilities

d)

Node-fetch does not provide error handling capabilities

78.

When should you use POST method in a REST API client?

a)

When you want to create a new resource on the server.

b)

When you want to perform a read-only operation on the server.

c)

When you want to retrieve data from the server.

d)

When you want to update an existing resource on the server.

79.

How can you handle authentication tokens in a REST API client?

a)

Store the authentication token in a plain text file on the client machine

b)

Embed the authentication token directly in the URL parameters of the HTTP request

c)

Send the authentication token in the request body as a JSON payload

d)

Include the authentication token in the Authorization header of the HTTP request with the 'Bearer' prefix.

80.

What is the role of status codes in HTTP responses?

a)

Status codes in HTTP responses are used for encryption purposes.

b)

Status codes in HTTP responses convey the outcome of the server's handling of the client's request.

c)

Status codes in HTTP responses are related to weather forecasting.

d)

Status codes in HTTP responses determine the color scheme of the website.

81.

How can you set headers in an axios request?

a)

Include headers directly in the URL

b)

Pass headers as a query parameter in the axios request

c)

Pass an object with key-value pairs representing the headers as the third argument in the axios request.

d)

Set headers using a separate fetch request

82.

What are the common status codes in HTTP responses and their meanings?

a)

200 OK, 404 Not Found, 500 Internal Server Error, 401 Unauthorized, 403 Forbidden

b)

500 Bad Request

c)

403 Unauthorized

d)

302 Found

83.

How can you handle timeouts in HTTP requests using axios?

a)

Ignore the timeout and proceed with the request

b)

Set a timeout value in the request configuration object

c)

Increase the number of retries

d)

Manually terminate the request process

84.

Which is the most famous backend technology which is based on JavaScript?

a)

Springboot

b)

Flask

c)
Node.js
d)

Django

85.

Which of the following is used for creating API's in JS?

a)
Node.js
b)
React.js
c)
Angular.js
d)
Express.js
86.
What is the primary use of Node.js?
a)
To build interactive user interfaces
b)
To develop mobile applications
c)
To write server-side applications
d)
To create graphics and animations
87.
Which of the following is true about Node.js?
a)
It's a compiled language
b)
It's single-threaded and asynchronous
c)
It's primarily used for desktop applications
d)
It's not suitable for web development
88.
What is the Node.js 'event loop' responsible for?
a)
Processing incoming HTTP requests
b)
Running JavaScript code asynchronously
c)
Managing database connections
d)
Handling server security
89.

What is Node.js primarily used for?

a)

Managing databases

b)

Building scalable network applications and web servers.

c)

Developing desktop software

d)

Creating mobile applications

90.

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

a)

Built-in support for multi-threading

b)

Synchronous file system access

c)

Single-threaded blocking model

d)

Non-blocking I/O model

91.

What does Express.js help you build?

a)

Desktop software and utilities

b)

Mobile applications and games

c)

Web applications and APIs

d)

Database management systems

92.

Which method is used to create a new Express application?

a)

createApp()

b)

express()

c)

new Express()

d)

initializeExpress()

93.

What is the default port for an Express server?

a)

4000

b)

5000

c)

8080

d)

3000

94.

Which of the following is a middleware in Express.js?

a)

body-parser

b)

morgan

c)

express-session

d)

cors

95.

What file is typically used to define dependencies in a Node.js project?

a)

config.json

b)

dependencies.json

c)

package.json

d)

node_modules.json

96.

Which command is used to install Express.js?

a)

npm install expressjs

b)

yarn add express

c)

npm add express

d)

npm install express

97.

What does the 'req' parameter represent in Express routes?

a)

The 'req' parameter is a placeholder for route parameters in Express.

b)

The 'req' parameter represents the response object in Express routes.

c)

The 'req' parameter represents the request object in Express routes.

d)

The 'req' parameter is used to define middleware in Express routes.

98.

Which of the following is NOT a core module of Node.js?

a)

http

b)

fs

c)

express

d)

path

99.

________ is a back end web application framework for Node.js, it is fast, unopinionated and minimalist framework.

a)

Emotional.js

b)

Express.js

c)

Nodemon

d)

Doraemon

100.

________ are the blocks of encapsulated code that communicates with an external application on the basis of their related functionality.

a)

Application

b)

Code

c)

Dependencies

d)

Modules

101.

What module provides information about the computer's operating system?

a)

OS Module

b)

Path Module

c)

FS Module

d)

HTTP Module

102.

What is the right syntax for importing a module?

a)

require()

b)

function()

c)

import()

d)

module.import()

103.

Do you need to know NodeJS before learning Express?

a)

Yes

b)

No

104.

What function arguments are available to Express.js Route handlers?

a)

req - the request object

b)

res - the response object

c)

next

d)

All of the above

105.

Where is captured values are populated regarding route parameters?

a)

req.params object

b)

app.locals object

c)

req.data object

d)

None of above

106.

What is a REST API?

a)

A client side scripting library

b)

A server side software application

c)

An application programming interface

107.

What is Express in Node.js?

a)

A POSIX tool used to transfer and buffer streams of data

b)

A database middleware wrapper

c)

A back end web framework

108.

What does CRUD stand for in the context of database operations?

a)

Create, Retrieve, Update, Delete

b)

Connect, Read, Update, Delete

c)

Connect, Retrieve, Update, Delete

d)

Create, Read, Update, Delete

109.

Which method is used to insert a single document into a MongoDB collection?

a)

insertMany()

b)

insertOne()

c)

addDocument()

d)

createDocument()

110.

What is the unique identifier field required in every MongoDB document?

a)

uniqueId

b)

documentId

c)

id

d)

_id

111.

Which MongoDB method is used to retrieve multiple documents from a collection?

a)

findOne()

b)

fetch()

c)

find()

d)

getAll()

112.

What does the upsert option do in the updateOne() method?

a)

Fetches a document

b)

Deletes a document if it exists

c)

Inserts a document if it does not exist

d)

Updates all documents

113.

Which operator is used to update a field in a MongoDB document?

a)

$set

b)

$update

c)

$add

d)

$modify

114.

What is BSON in MongoDB?

a)

Binary JSON

b)

Binary Object

c)

Basic JSON

d)

Basic Object Notation

115.

Which method is used to delete multiple documents from a MongoDB collection?

a)

deleteMany()

b)

deleteAll()

c)

removeMany()

d)

removeAll()

116.

What is the purpose of the findOne() method?

a)

To delete a document

b)

To update a document

c)

To find all documents

d)

To find a single document that matches a query

117.

In which format does MongoDB store data?

a)

CSV

b)

BSON

c)

HTML

d)

XML

118.

What is the default behavior of insertMany() regarding document order?

a)

Ordered

b)

Unordered

c)

Random

d)

Sequential

119.

Which method would you use to update multiple documents at once?

a)

bulkUpdate()

b)

updateMany()

c)

updateMultiple()

d)

updateAll()

120.

What is the purpose of the $gte operator in a query?

a)

Not equal to

b)

Greater than or equal to

c)

Less than or equal to

d)

Equal to

121.

Which of the following is a valid way to connect to a MongoDB database in Node.js?

a)

db.connect()

b)

connectMongo()

c)

MongoDB.connect()

d)

MongoClient.connect()

122.

What is Mongoose in the context of MongoDB?

a)

A GUI tool for managing MongoDB databases.

b)

An ODM library for MongoDB and Node.js

c)

A database clustering solution

d)

A schema-less database engine

123.

Which feature of Mongoose helps in defining the structure of the documents within a collection?

a)

Model Validation

b)

Schema Definition

c)

Query Building

d)

Data Aggregation

124.

Why would you use Mongoose instead of the native MongoDB driver in a Node.js application?

a)

It provides a GUI for database management

b)

It allows for schema enforcement and validation

c)

It is faster than the native driver

d)

It supports SQL queries

125.

What is a virtual in Mongoose, and how is it used?

a)

A special field that exists only in the application's memory, not in the database

b)

A method to create indexes on fields

c)

A feature to define relationships between documents

d)

A way to handle transactions in MongoDB

126.

How do you create a model from a schema in Mongoose?

a)

mongoose.createModel('ModelName', schema)

b)

mongoose.model('ModelName', schema)

c)

mongoose.newModel('ModelName', schema)

d)

mongoose.makeModel('ModelName', schema)

127.

How does Mongoose handle relationships between documents in MongoDB?

a)

By embedding documents within each other

b)

By using virtuals to simulate joins

c)

By referencing documents through ObjectIds

d)

All of the above

128.

Which Mongoose feature allows for the automatic population of referenced documents?

a)

Middleware

b)

Hooks

c)

Virtuals

d)

Populate

129.

Which option sets a field as required in a Mongoose schema?

a)

{ required: true }

b)

{ mandatory: true }

c)

{ necessary: true }

d)

{ compulsory: true }

130.

How do you connect to a MongoDB database using Mongoose?

a)

mongoose.start()

b)

mongoose.db('mongodb://localhost/mydb')

c)

mongoose.connect('mongodb://localhost/mydb')

d)

mongoose.init('mongodb://localhost/mydb')

131.

Why did the MongoDB document go to therapy?

a)

It had too many issues

b)

It was feeling unstructured

c)

It couldn't find a primary key

d)

It had a complex relationship