0% found this document useful (0 votes)
3 views

Nodejs Beginner Questions

Questions on nodejs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Nodejs Beginner Questions

Questions on nodejs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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

A) npm init
B) npm start
C) npm create
D) npm setup

Which function is used to handle errors in Node.js?

A) handleError()
B) try...catch
C) errorHandler()
D) catchError()

What does the path.join() method do in Node.js?

A) It merges multiple paths into a single path


B) It reads file content
C) It writes data to a file
D) It deletes a file

How do you create a new file in Node.js?

A) fs.createFile()
B) fs.newFile()
C) fs.writeFile()
D) fs.addFile()

What is the purpose of the res.json() method in Express.js?

A) To send a JSON response to the client


B) To parse JSON data from the client
C) To format response as XML
D) To redirect to another URL

What is the purpose of the node command?

A) To install Node.js
B) To execute a JavaScript file with Node.js
C) To start a web server
D) To initialize a new project

What is the primary purpose of Node.js modules?


A) To create graphical user interfaces
B) To organize and reuse code
C) To manage databases
D) To handle HTTP requests
Which method is used to export functions or variables from a Node.js module?
A) module.exports
B) exports.module
C) export
D) module.export

Which of the following best describes a client-server architecture?


Answer: A distributed system where clients request services from a central server.

What does app.use() do in Express.js?

A) It defines a new route


B) It applies middleware functions to incoming requests
C) It sets the server port
D) It sends a response to the client

The client in a client-server architecture typically:


Answer: Requests services from the server.

Which of the following is NOT a common type of client-server architecture?


Two-tier architecture. Three-tier architecture. N-tier architecture. Peer-to-peer
architecture.

Which of the following protocols is commonly used in client-server communication?


HTTP FTP SMTP All of the above

A firewall is a security measure often used in client-server architecture to:


Protect the server from unauthorized access. Encrypt data transmitted between client
and server. Prevent denial-of-service attacks. All of the above.

In a client-server model, who makes a request for a service?


The server The client The network Both client and server

What is the main role of a server in a client-server model?


To provide services to clients To process data locally To request services from other
servers To communicate with the network

Which of the following is an example of a client in a client-server model?


A web browser A database server A mail server A network switch

What is the term for a computer that provides resources to other computers?
Server
Which of the following is NOT a common type of client-server application?
Email Online banking File sharing Word processing

When a client sends a request to a server, the first thing the server typically does is:
Process the request. Send a response. Establish a connection. Store the request
data.
The part of a web server that processes incoming requests is called:
Web browser. Web application. Web server software. Web page.

What is the term for the process of breaking down a large task into smaller subtasks that can
be executed concurrently?
Load balancing. Threading. Caching Multiplexing.

A web server can handle multiple requests simultaneously by using:


A single thread. Multiple threads. A single process. Multiple threads or
processes.

What is Node.js primarily used for?

A) Front-end development
B) Backend development
C) Database management
D) Desktop applications

Which language is Node.js built on?

A) Python
B) JavaScript
C) Java
D) Ruby

Which module in Node.js is used to create an HTTP server?

A) fs
B) path
C) http
D) url

Load balancing is used to:


Distribute incoming requests across multiple servers. Improve the speed of a single
server. Increase the storage capacity of a server. Enhance security.

What does the npm command stand for?

A) Node Package Manager


B) Node Project Manager
C) New Package Manager
D) Network Package Manager

How do you install a package using npm?


A) npm get <package-name>
B) npm download <package-name>
C) npm install <package-name>
D) npm add <package-name>

What is the purpose of the package.json file in a Node.js project?

A) To store configuration settings


B) To manage project dependencies
C) To define project structure
D) To write the application code

In Express.js, what does the app.listen() function do?

A) It creates a new route


B) It starts the server to listen for incoming requests
C) It sends a response to the client
D) It handles database connections

Which of the following methods is used to read a file in Node.js?

A) fs.readFile()
B) fs.openFile()
C) fs.loadFile()
D) fs.getFile()

How can you create a simple HTTP server in Node.js?

A) Using the fs module


B) Using the http module
C) Using the path module
D) Using the url module

Which method is used to send a response back to the client in Express.js?

A) res.send()
B) res.write()
C) res.response()
D) res.finish()

What is a middleware function in Express.js?

A) A function that handles HTTP requests


B) A function that processes data before sending a response
C) A function that manages file uploads
D) A function that creates routes

How do you import a module in Node.js?

A) import <module-name>
B) require(<module-name>)
C) load(<module-name>)
D) include(<module-name>)

Which of the following is used to handle promises rejections in Node.js?


A) .catch()
B) .fail()
C) .error()
D) .reject()
How can you handle errors thrown by synchronous code in Node.js?
A) By using try...catch blocks
B) By using process.on('error')
C) By using errorHandler()
D) By using promise.catch()

How do you handle errors in asynchronous functions in Node.js?


A) By using try...catch blocks
B) By using the error event
C) By passing errors to a callback function
D) By using the Promise object

What is the purpose of the process.on('uncaughtException') event?


A) To handle errors in asynchronous code
B) To log uncaught exceptions that occur in the application
C) To handle HTTP request errors
D) To manage module exports

How do you import a specific function from a module in Node.js?


A) const { functionName } = require('module-name');
B) import functionName from 'module-name';
C) require('module-name').functionName;
D) load('module-name', 'functionName');

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


A) To provide a method for importing modules
B) To define the public API of a module
C) To manage internal module dependencies
D) To handle HTTP requests

You might also like