Learn Node Js MCQs

Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.

How do you merge path segments into one path in Node.js?

1) path.resolve()

2) path.normalize()

3) path.join()

4) path.concat()

Answer : Option 3

Which method is used to pause a readable stream in Node.js?

1) stream.pauseRead()

2) stream.stop()

3) stream.pause()

4) stream.end()

Answer : Option 3

What does the `Buffer.byteLength()` method return?

1) The length of a buffer in kilobytes

2) The total memory used by the buffer

3) The length of a buffer in bytes

4) The length of a buffer in characters

Answer : Option 3

Which method is used to create a transform stream in Node.js?

1) stream.Transform()

2) stream.TransformStream()

3) new stream.Transform()

4) stream.createTransform()

Answer : Option 3

What is the purpose of `os.homedir()` in Node.js?

1) To get the hostname of the system

2) To get the OS type

3) To get the home directory of the current user

4) To get the current working directory

Answer : Option 3

How do you handle multiple promises in parallel in Node.js?

1) Promise.allSettled()

2) Promise.race()

3) Promise.all()

4) Promise.chain()

Answer : Option 3

Which module in Node.js is used to compress and decompress files?

1) zlib

2) zip

3) gzip

4) compressor

Answer : Option 3

What does the `cluster.isMaster` property indicate?

1) If the cluster is a worker

2) If the cluster is a fork

3) If the cluster is the master process

4) If the cluster is a slave process

Answer : Option 3

How do you get the directory name of the current module in Node.js?

1) __filename

2) __cwdname

3) __currentdir

4) __dirname

Answer : Option 3

Which method is used to return the last portion of a path in Node.js?

1) path.end()

2) path.resolve()

3) path.basename()

4) path.finish()

Answer : Option 3