Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

Which method asynchronously reads the entire contents of a file?
A. fs.open()
B. fs.readSync()
C. fs.read()
D. fs.readFile()
Direction: Choose the correct option

Q2.

If no encoding is specified in `fs.readFile()`, what is returned?
A. An array
B. An error
C. A string
D. A buffer
Direction: Choose the correct option

Q3.

How do you read a file line by line in Node.js?
A. Using the `readline` module
B. Using `fs.readFile()` and splitting by newline
C. All of the above are possible
D. Using `fs.createReadStream()` with `readline`
Direction: Choose the correct option

Q4.

What happens if the file does not exist in `fs.readFile()`?
A. The program crashes
B. The callback receives an error object
C. `null` is returned
D. An empty file is created
Direction: Choose the correct option

Q5.

Which flag would you use with `fs.open()` to read a file?
A. 'x'
B. 'w'
C. 'a'
D. 'r'