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?
process
Buffer
root
require
Q35. What is the command to get a list of available commands for Node.js?What is the command to get a list of available commands for Node.js?
node index.js -x
node -v
node -h
node index.js -h
Q36. When a request event is received in the HTTP module, what is the type of the first argument passed to that event, usually named req?
http.IncomingMessage
http.ServerRequest
http.ClientRequest
http.ServerResponse
Q37. What are the arguments passed to the module wrapper function?
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?
buffer
util
string_decoder
string_buffer
Q50. Which global object acts like a bridge between a Node script and the host operating system?
v8
env
process
child_process
Explanation: _process is an global object and act like a bridge, the others aren’t
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.
Q64. Which assert module method is usually used to test the error-first argument in callbacks?
fail
doesNotThrow
deepStrictEqual
ifError
Q65. Which choice is not a method on the util module?
promisify
asyncify
types
callbackify
Q66. Which choice is not a subclass of the Error class?
GlobalError
TypeError
RangeError
AssertionError
Q67. What is Node built on?
Python
V8 JavaScript engine
PHP
c
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 executon 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?
EventLoop
Libuv
Google V8
Express.js
Q70. What is the importance of having good practices around status code in your response?
It indicates success or failure to the client and helps with testing.
It is not important to have good practices regarding status codes
Response codes are the only way you can tell what is happening on the server.
It contains information about the current performance of the server.
Q71. How can ECMAScript modules be used natively in Node?
ECMAScript modules cannot be used natively in Node.
ECMAScript modules can be used natively in Node with the .mjs file extension
ECMAScript modules can be used natively in Node only by using a compiler like Babel.
ECMAScript modules can be used natively in Node only by using a bundle like webpack.
Q72. When exploring the Node documentation’s features, what are the stability ratings?
They are an indication of the stability of Nodejs modules and usage recommendations.
They tell if a feature is ES6 compliant.
They are a Node command to validate stability of your code.
They tell if a feature is LTS (Long Term Supported).
Q73. Which of the following DNS module methods uses the underlying OS facilities and does not necessarily perform any network communication?