to provide utilities to play with file and directory paths
to provide utilities to add and remove files
It is a retiring module.
to provide utilities to test files
Q26. How do you make an HTTP server object active and listen to requests on certain ports?
server. start
server.activate
server.listen
server. run
Q27. What does the code shown below do?
const fs = require('fs'); const os = require('os');
const system = os.platform(); const user = os.userInfo().username;
fs.appendFile('hello.txt', `Hello ${user} on ${system}`, (err) => { if (err) throw err; console.log('The data was appended to file!');}
);
creates a text file hello.txt and appends customized text
creates an image file
console logs system information
creates a file named data and append numbers
Q28. How do you start a Node application, if the entry file is indexjs?
nodemon start
start index.js
node index.js
node start
Q29. What is the purpose of the file system (fs) module?
to provide methods to work with requests and responses
to provide methods to work with files
to provide methods to work with databases
to find new file systems
Q30. What is the Node LTS version?
It is the current unstable version and is to be avoided.
It is the version that will be retired soon.
It is the version with the latest features.
It is the safest version for long-term support.
Q31. Which of the following is NOT a valid stream in Node?
process. stdinfo
process. stdin
process. stdout
process. stderr
Q32. You have a script.js file with the single line of code shown here. What will be the output of executing script.js with the node command?
console.log(arguments);
ReferenceError: arguments is not defined
an empty string
undefined
an object representing an array that has five elements
Q33. Which choice is not a valid method on event emitters?
start
on
once
off
Q34. Which special object is an instance of EventEmitter?Which special object is an instance of null?
Q44. According to the rules of semantic versioning, what does a release incrementing the third number in an npm version string communicate to users about the release changes?
Changes are not backwards compatible.
Changes might not be backward compatible and might break existing code.
Changes are just bug fixes and no new features were added.
Changes will add new functionality but will not break any existing code.
Q45. What does REPL stand for?
run, examine, put, loop
read, eval, print, loop
run, edit, print, loop
read, extend, print, loop
Q46. Which file does node-gyp use to read the build configuration of a module?
.gyprc
binding.gyp
gyp.json
package.gyp
Q47. Which core module in Node can you use for testing?
chai
jest
assert
mocha
Q48. Which core module in Node provides an API to register callbacks to track asynchronous resources created inside a Node.js application?
cluster
async_hooks
dgram
inspector
Q49. Which Node.js module should you use when you need to decode raw data into strings?
Q55. You have to read a large text file, replace some words in it, and write it back to a new file. You know that the memory on your target system is limited. What should you do?
Use regular expressions directly on the file.
Use Promises and async/await to offload the task to libuv.
Copy the file into a database and perform the operations there.
Use readline together with streams to read and transform and write the file contents line by line.
Q68. How does it affect the performance of a web application when an execution path contains a CPU-heavy operation, such as calculating a long Fibonacci sequence?
As Node.js is asynchronous, this is handled by a libuv and a threadpool. The performance will not notably degrade.
As the application code runs asynchronously within a single thread, the execution will block, accepting no more requests until the operation is completed.
As Node.js is asynchronous, this is handled by a threadpool and the performance will not notably degrade.
The current thread will block until the execution is completed and the operating system will spawn new threads to handle incoming requests. This can exhaust the number of allowed threads (255) and degrade performance over time.
Q69. What is used for parsing and running Javascript in Node.js?
Q76. When you require(something), where will Node.js attempt to resolve(something)?
the local .modules folder, then the parents’ node_modules folder
the local node_modules folder, then the parents’ node_modules folder
the .modules folder under the home directory
a “something.js” file or a “something” folder, which exist on the same level as the requiring file
Q77. An external library has its own codebase and license. It is not managed by the Node.js core team. Which choice is an external library that Node.js uses?
net
openssl
cluster
events
Q78. What is the main purpose of the package-lock.json file?
to be a system file
to provide an exact, single representation of the dependency tree
to serve as a module to export dependencies
to be a log for the application
Q79. How would you determine the number of cluster instances to start when using the cluster module?
const numInstances = process.cpus().length
const numInstances = cluster.instances().length
const numInstances = cluster.instances()
const numInstances = require('os').cpus().length
Q80. What response will you get when you send a get requests to the server with this code?