curriculum/challenges/english/blocks/quiz-node-js-core-modules/692487767b6b728454f53f29.md
To pass the quiz, you must correctly answer at least 18 of the 20 questions below.
Which fs method adds content to an existing file without overwriting it?
writeFile()
readFile()
unlink()
appendFile()
What happens when you use synchronous methods from the fs module?
They delete existing files automatically.
They run faster than asynchronous ones in all cases.
They return Promises by default.
They block the program until the operation finishes.
What does the utf8 parameter do in fs.readFile()?
It prevents errors from being thrown.
It changes the file’s extension.
It compresses large files.
It tells Node to return a readable string instead of a buffer.
Which Buffer method creates a new buffer filled with zeros?
Buffer.from()
Buffer.concat()
Buffer.byteLength()
Buffer.alloc()
What does Buffer.toString() do?
Converts a buffer into binary code.
Clears the contents of a buffer.
Shows buffer byte length.
Converts buffer contents into a readable string.
Which crypto feature requires a private key to generate a signature?
createHash()
createCipheriv()
randomBytes()
sign()
Why should you avoid writing your own crypto algorithms directly?
It is illegal in Node.js applications.
Node.js does not support encryption.
JavaScript cannot compute hashes.
It can be unsafe without well-tested libraries.
What crypto method is recommended for generating secure random tokens instead of Math.random()?
randomInt()
createHmac()
createCipheriv()
randomBytes()
Which OS module method returns the CPU architecture?
os.cpus()
os.platform()
os.version()
os.arch()
What does os.userInfo() return?
Only the username.
Only the device IP address.
Only the logged-in user’s ID.
Information about the current system user.
Which path method joins segments and normalizes extra slashes?
path.resolve()
path.extname()
path.dirname()
path.join()
Which path method produces an absolute path based on the current working directory?
path.extname()
path.format()
path.parse()
path.resolve()
What does the global variable __dirname represent?
The name of the user running Node.
The current file’s extension.
A relative folder path starting with ./.
The absolute path of the directory containing the current file.
Which process property contains environment variables like NODE_ENV?
process.cwd
process.version
process.platform
process.env
What does the process.on("exit") event do?
It restarts the Node application.
It sends an exit signal to child processes.
It clears the event loop queue.
Executes code right before the Node process finishes.
Which stream type can both read and write data but does not transform it?
Readable stream
Transform stream
Writable stream
Duplex stream
What is required to implement reading and writing of large files efficiently?
Using only Buffer.alloc()
Importing the crypto module
Saving the entire file in memory first
Using streams to process data in chunks
Which method links a readable stream to a writable stream?
pipeTo()
connect()
streamWrite()
pipe()
What stream event indicates there is no more data to write?
close
drain
end
finish
What is logged if you print a chunk from a readable stream without toString()?
Plain text content
The process PID
Operating system name
A buffer object with binary data