Node.js Quiz | Set-1

Question 1
Node.js is written in
Cross
JavaScript
Cross
C
Cross
C++
Tick
All of the above


Question 1-Explanation: 
Node.js is a backend JavaScript Framework. NodeJS is written on JavaScript, C, C++.
Question 2
How modules in Node.js can be connected from one component to another ?
Cross
Expose
Cross
Module
Tick
Exports
Cross
All of the above


Question 2-Explanation: 
Exports in Node.js are used to export the component from one module to another. It can also export to literal, function, or object. It is responsible for including the JavaScript file into the node.js applications.
Question 3
Which of the below modules is not a built-in module in Node.js ?
Cross
zlib
Cross
HTTPS
Cross
dgram
Tick
fsread


Question 3-Explanation: 
The fsread modules is not a built-in node module in Node.js. Reading and writing are performed in all of the applications. Node.js has many inbuild modules to perform read and write the application.fs package contains the function required in file operations.
Question 4
Which of the below command will show all the modules installed locally ?
Cross
npm ls -g
Tick
npm ls
Cross
node ls -g
Cross
node ls


Question 4-Explanation: 
The npm ls command print all the versions of packages that are installed locally in the system, It also displays all the dependencies that are present in the tree structure.
Question 5
Which of the below fs module is used to truncate a file ?
Cross
fs.delete(fd, len, callback)
Cross
fs.remove(fd, len, callback)
Tick
fs.ftruncate(fd, len, callback)
Cross
None of the above.


Question 5-Explanation: 
The fs.ftruncate() method in Node.js is used to change the size of the files It increases or decreases the size of the file. Or it changes the length of the file by len bytes If len is shorter than the file’s current length, the file is truncated to that length. It takes 3 parameters as fd, len, and callback.
Question 6

Which template engines can be used with Node.js ?

Cross

Jade

Cross

Vash

Cross

Handlebars

Tick

All of the above



Question 6-Explanation: 

Jade, Vash, and Handlebars are template engines that can be used with Node.js. 

Question 7
How do we return a path string from the given path object in Node.js ?
Cross
path.get()
Cross
path.set()
Tick
path.format()
Cross
path.return()


Question 7-Explanation: 
The path. format() method is used to return a path string from the given path object. The method has some rules where one path property gets more priority over another.
Question 8

What is the default scope in the Node.js application ?

Cross

Global

Tick

Local

Cross

Global Function

Cross

Local to object



Question 8-Explanation: 

Local is the default scope in the Node.js application. Local variables are defined within the function. Variable has the local scope it means that they can only be used within the function that defines them.

// 2 option is the same, and is mentioned as "A" but in the explanation it is B

Question 9
Which of the below method is used to return the current working directory of the process ?
Tick
cwd();
Cross
cmd();
Cross
pwd();
Cross
None of the above


Question 9-Explanation: 
The cwd() method in Node.js is used to get the current working directory of the process.
Question 10
Which below method is used to check whether the given path is an absolute path or not in Node.js ?
Cross
path.Query()
Cross
path.render()
Tick
path.isAbsolute()
Cross
path.Absolute()


Question 10-Explanation: 
The path.isAbsolute() tell the path is absolute or not. It needed complete detail to locate the file. It accepts a single parameter A. The return value in this method specifies the path is absolute or not if it returns false as a value it means that path ios on zero-length.
There are 15 questions to complete.


  • Last Updated : 27 Sep, 2023

Share your thoughts in the comments
Similar Reads