Learn Node Js MCQs
Prepare Node Js MCQs (Multiple choice Questions) for exam and job interviews.
What is the purpose of `stream.finished()` in Node.js?
1) To indicate that the stream is about to close
2) To start a stream
3) To check if a stream has finished
4) To destroy a stream
Answer : Option 3
How do you handle signal events in Node.js?
1) process.onSignal()
2) process.signal()
3) process.on()
4) process.handle()
Answer : Option 3
Which method is used to create a child process in Node.js?
1) process.fork()
2) process.spawn()
3) child_process.spawn()
4) child_process.run()
Answer : Option 3
What does the `path.extname()` method return?
1) The file name
2) The directory name
3) The extension of a file
4) The full path of a file
Answer : Option 3
How do you convert a callback-based function to return a promise in Node.js?
1) util.promisifyify()
2) util.promise()
3) util.promisify()
4) util.callbackify()
Answer : Option 3
Which method is used to encode a URL in Node.js?
1) url.stringify()
2) url.resolve()
3) encodeURIComponent()
4) url.encode()
Answer : Option 3
What does the `stream.pipeline()` method do?
1) Closes a stream
2) Opens a stream
3) Pipes a series of streams together
4) Destroys a stream
Answer : Option 3
Which module in Node.js is used to provide cryptographic functionality?
1) secure
2) cipher
3) crypto
4) encryptor
Answer : Option 3
How do you catch all unhandled promise rejections in a Node.js application?
1) promise.catch()
2) process.onUnhandled()
3) process.reject()
4) process.on('unhandledRejection')
Answer : Option 3
What is the purpose of `http.get()` in Node.js?
1) To send data to a server
2) To create an HTTP server
3) To make a GET request to an HTTP server
4) To create an HTTP client
Answer : Option 3