Node.js Quiz | Set-1

  • Last Updated : 30 Sep, 2021

Question 1
Node.js is written in
A
JavaScript
B
C
C
C++
D
All of the above
Node.js Quiz | Set-1    
Discuss it


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 ?
A
Expose
B
Module
C
Exports
D
All of the above
Node.js Quiz | Set-1    
Discuss it


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 ?
A
zlib
B
HTTPS
C
dgram
D
fsread
Node.js Quiz | Set-1    
Discuss it


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 ?
A
npm ls -g
B
npm ls
C
node ls -g
D
node ls
Node.js Quiz | Set-1    
Discuss it


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 ?
A
fs.delete(fd, len, callback)
B
fs.remove(fd, len, callback)
C
fs.ftruncate(fd, len, callback)
D
None of the above.
Node.js Quiz | Set-1    
Discuss it


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 ?

A

Jade

B

Vash

C

Handlebars

D

All of the above

Node.js Quiz | Set-1    
Discuss it


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 ?
A
path.get()
B
path.set()
C
path.format()
D
path.return()
Node.js Quiz | Set-1    
Discuss it


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 ?

A

Global

B

Local

C

Global Function

D

Local to object

Node.js Quiz | Set-1    
Discuss it


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 ?
A
cwd();
B
cmd();
C
pwd();
D
None of the above
Node.js Quiz | Set-1    
Discuss it


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 ?
A
path.Query()
B
path.render()
C
path.isAbsolute()
D
path.Absolute()
Node.js Quiz | Set-1    
Discuss it


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.
My Personal Notes arrow_drop_up