node js banner

Node JS Multiple Choice Questions (MCQs) and Answers

Master Node JS with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Node JS concepts. Begin your placement preparation journey now!

Q1

Q1 What is Node.js primarily used for?

A

To create client-side interfaces

B

To act as a DBMS

C

To build server-side applications

D

To enhance CSS

Q2

Q2 Which engine powers Node.js?

A

V8

B

SpiderMonkey

C

JavaScriptCore

D

Chakra

Q3

Q3 Node.js is designed to handle which type of operations efficiently?

A

Synchronous

B

Asynchronous

C

Parallel

D

Serial

Q4

Q4 Which programming language is Node.js based on?

A

Python

B

Java

C

JavaScript

D

Ruby

Q5

Q5 What type of architecture does Node.js follow?

A

Blocking I/O

B

Non-blocking I/O

C

Procedural

D

Functional

Q6

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

A

Synchronous execution

B

Single-threaded

C

Multi-threaded

D

Distributed

Q7

Q7 Which protocol is primarily used in Node.js for communication?

A

FTP

B

HTTP

C

SMTP

D

SNMP

Q8

Q8 What is the main advantage of using Node.js for web applications?

A

High CPU usage

B

Low memory usage

C

Non-blocking I/O

D

Static typing

Q9

Q9 Which method is used to import modules in Node.js?

A

require()

B

import()

C

include()

D

module()

Q10

Q10 What is a core module in Node.js?

A

A user-defined module

B

A built-in module

C

A plugin

D

An external library

Q11

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

A

fs

B

express

C

mongoose

D

socket.io

Q12

Q12 Which object is used to manage modules in Node.js?

A

global

B

module

C

process

D

exports

Q13

Q13 How can you export multiple functions from a module?

A

module.exports

B

exports

C

global

D

process

Q14

Q14 Which of the following is true about the 'require' function?

A

It blocks the event loop

B

It is asynchronous

C

It is non-blocking

D

It can load JSON files

Q15

Q15 How do you import the 'http' module in Node.js?

A

const http = require('http');

B

import http from 'http';

C

include http

D

http = require('http');

Q16

Q16 What is the output of
console.log(module.exports === exports);

A

true

B

false

C

undefined

D

null

Q17

Q17 How do you make a function available outside a module?

A

exports.functionName = function(){};

B

module.exports = function(){};

C

global.functionName = function(){};

D

process.functionName = function(){};

Q18

Q18 What should you do if a module is not found?

A

Reinstall Node.js

B

Check module spelling

C

Use a different IDE

D

Update npm

Q19

Q19 An application crashes with "Error: Cannot find module".
What should be checked?

A

Node version

B

Module installation

C

Network connection

D

Disk space

Q20

Q20 Which method reads the content of a file in Node.js?

A

fs.readFile

B

fs.open

C

fs.read

D

fs.write

Q21

Q21 Which method writes data to a file in Node.js?

A

fs.readFile

B

fs.writeFile

C

fs.open

D

fs.appendFile

Q22

Q22 What does the fs.unlink method do in Node.js?

A

Reads a file

B

Writes to a file

C

Deletes a file

D

Renames a file

Q23

Q23 Which method is used to open a file in Node.js?

A

fs.readFile

B

fs.open

C

fs.write

D

fs.unlink

Q24

Q24 How can you read the content of a directory in Node.js?

A

fs.readDir

B

fs.readDirectory

C

fs.readdir

D

fs.read

Q25

Q25 Which method is used to append data to a file in Node.js?

A

fs.appendFile

B

fs.writeFile

C

fs.addData

D

fs.insert

Q26

Q26 How do you read a file named 'example.txt' in Node.js?

A

fs.readFile('example.txt', callback)

B

fs.open('example.txt', callback)

C

fs.read('example.txt', callback)

D

fs.readFile('example.txt')

Q27

Q27 What is the output of fs.readFileSync('example.txt')?

A

A promise

B

A buffer

C

An error

D

A string

Q28

Q28 How do you check if a file exists in Node.js?

A

fs.existsSync('example.txt')

B

fs.checkFile('example.txt')

C

fs.exists('example.txt')

D

fs.fileExists('example.txt')

Q29

Q29 What should you do if fs.readFile returns an error?

A

Retry reading the file

B

Check the file path

C

Change file permissions

D

Reboot the system

Q30

Q30 How can you handle errors when writing to a file in Node.js?

A

Use a try-catch block

B

Ignore errors

C

Reopen the file

D

Restart Node.js

...
ad verticalad vertical
ad