Loading

Quipoin Menu

Learn • Practice • Grow

node-js / File System Basics
mcq
Direction: Choose the correct option

Q1.

Which module is used for file operations in Node.js?
A. file
B. filesystem
C. fs
D. io
Direction: Choose the correct option

Q2.

What is the difference between `fs.readFile()` and `fs.readFileSync()`?
A. `readFile` is asynchronous, `readFileSync` is synchronous
B. `readFile` is for small files only
C. One reads text files, the other reads binary
D. There is no difference
Direction: Choose the correct option

Q3.

How do you include the `fs` module in your script?
A. const fs = require('fs');
B. include('fs');
C. import fs from 'fs';
D. Both A and B are valid (depending on module system)
Direction: Choose the correct option

Q4.

What does `fs.writeFile()` do?
A. Reads a file
B. Writes data to a file (replacing if exists)
C. Deletes a file
D. Appends data to a file
Direction: Choose the correct option

Q5.

In `fs.readFile`, what does the callback function receive?
A. An error object and the file data
B. The file descriptor
C. Only an error object
D. Only the file contents