PrepIQ Certified NodeJS Developer Ultimate Exam, Exams of Technology

Covers Node.js programming, asynchronous development, APIs, database integration, application security, testing methodologies, and backend development techniques.

Typology: Exams

2025/2026

Available from 06/12/2026

shilpi-jain-2
shilpi-jain-2 🇮🇳

1

(1)

25K documents

1 / 49

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PrepIQ Certified NodeJS Developer
Ultimate Exam
**Question 1.** Which of the following statements best describes the purpose of
the `require()` function in a Node.js CommonJS module?
A) It creates a new global variable.
B) It imports a module synchronously at runtime.
C) It compiles TypeScript code to JavaScript.
D) It starts the Node.js event loop.
Answer: B
Explanation: `require()` loads and caches a module synchronously, making its
exported values available to the calling file.
**Question 2.** In Node.js, which core module provides the `EventEmitter` class?
A) `fs`
B) `http`
C) `events`
D) `util`
Answer: C
Explanation: The `events` module defines the `EventEmitter` class, which is the
basis for handling events in Node.js.
**Question 3.** What will the following code output?
```js
console.log(typeof process.nextTick);
```
A) `"function"`
B) `"object"`
C) `"undefined"`
D) `"string"`
Answer: A
Explanation: `process.nextTick` is a function that schedules a callback to run
after the current operation completes but before the event loop continues.
**Question 4.** Which of the following is true about the Node.js event loop
phases?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31

Partial preview of the text

Download PrepIQ Certified NodeJS Developer Ultimate Exam and more Exams Technology in PDF only on Docsity!

Ultimate Exam

Question 1. Which of the following statements best describes the purpose of the require() function in a Node.js CommonJS module? A) It creates a new global variable. B) It imports a module synchronously at runtime. C) It compiles TypeScript code to JavaScript. D) It starts the Node.js event loop. Answer: B Explanation: require() loads and caches a module synchronously, making its exported values available to the calling file. Question 2. In Node.js, which core module provides the EventEmitter class? A) fs B) http C) events D) util Answer: C Explanation: The events module defines the EventEmitter class, which is the basis for handling events in Node.js. Question 3. What will the following code output?

console.log(typeof process.nextTick);

A) "function" B) "object" C) "undefined" D) "string" Answer: A Explanation: process.nextTick is a function that schedules a callback to run after the current operation completes but before the event loop continues. Question 4. Which of the following is true about the Node.js event loop phases?

Ultimate Exam

A) Timers callbacks are executed after I/O callbacks. B) setImmediate callbacks run before process.nextTick. C) I/O callbacks are processed after the poll phase. D) process.nextTick callbacks are executed after the poll phase. Answer: C Explanation: I/O callbacks are processed in the poll phase, which follows the timers phase. process.nextTick callbacks run after each phase, before the loop proceeds. Question 5. In an Express.js route handler, which method is used to parse JSON request bodies automatically? A) app.use(express.urlencoded()) B) app.use(express.json()) C) app.use(bodyParser.raw()) D) app.use(cookieParser()) Answer: B Explanation: express.json() is middleware that parses incoming JSON payloads and makes them available on req.body. Question 6. Which of the following statements about Node.js streams is correct? A) All streams are readable and writable simultaneously. B) A readable stream can be piped into a writable stream. C) Streams cannot be paused once started. D) Streams always operate in object mode by default. Answer: B Explanation: Readable streams can be piped into writable streams, allowing data to flow without buffering the entire content in memory. Question 7. What does the cluster module enable in a Node.js application? A) Automatic load balancing across multiple CPU cores. B) Real-time communication with WebSockets. C) Encryption of HTTP traffic.

Ultimate Exam

Question 11. What is the default maximum number of listeners per event in Node.js's EventEmitter before a memory leak warning is emitted? A) 5 B) 10 C) 15 D) Unlimited Answer: B Explanation: Node.js issues a warning after more than 10 listeners are added for a single event, to help detect potential memory leaks. Question 12. Which of the following correctly creates a writable file stream using the fs module? A) fs.createWriteStream('/tmp/file.txt', { flags: 'r' }) B) fs.createReadStream('/tmp/file.txt') C) fs.createWriteStream('/tmp/file.txt') D) fs.open('/tmp/file.txt', 'w') Answer: C Explanation: fs.createWriteStream opens a stream for writing; the default flag is 'w'. Option A uses the read flag, which is incorrect. Question 13. In Node.js, which method is used to schedule a callback to run after the current event loop turn, but before any I/O events? A) setTimeout(fn, 0) B) setImmediate(fn) C) process.nextTick(fn) D) requestAnimationFrame(fn) Answer: C Explanation: process.nextTick callbacks execute immediately after the current operation, before the event loop proceeds to the next phase. Question 14. What does the Buffer.from('hello') call return? A) A string "hello"

Ultimate Exam

B) An array [104,101,108,108,111] C) A Buffer containing the UTF-8 bytes of "hello" D) A Uint8Array view of the string Answer: C Explanation: Buffer.from creates a Buffer object containing the binary representation (UTF-8 by default) of the input string. Question 15. Which HTTP status code indicates that the client must authenticate to gain network access? A) 401 B) 403 C) 404 D) 500 Answer: A Explanation: Status code 401 (Unauthorized) signals that authentication is required. Question 16. In Express.js, which method is used to mount middleware that only applies to routes starting with /api? A) app.use('/api', middleware) B) app.all('/api', middleware) C) app.get('/api', middleware) D) app.route('/api').use(middleware) Answer: A Explanation: app.use with a path prefix mounts the middleware for any request whose path begins with that prefix. Question 17. Which of the following is NOT a built-in Node.js module? A) crypto B) url C) lodash D) path Answer: C

Ultimate Exam

Question 21. In a Node.js REPL, which command clears the console screen? A) .clear B) .cls C) clear() D) process.clearScreenDown() Answer: A Explanation: The REPL provides the .clear command to clear the screen. Question 22. Which of the following correctly creates an HTTPS server using the https core module? A) https.createServer(options, app).listen(443); B) http.createSecureServer(options, app).listen(443); C) tls.createServer(options, app).listen(443); D) https.createSecureServer(app).listen(443); Answer: A Explanation: https.createServer takes TLS options (key, cert) and a request listener, then you call .listen. Question 23. What is the purpose of the package-lock.json file? A) To list all development dependencies. B) To lock the exact versions of installed packages for reproducible installs. C) To configure linting rules for the project. D) To define environment variables for production. Answer: B Explanation: package-lock.json records the full dependency tree with exact version numbers, ensuring identical installations across environments. Question 24. Which Node.js API is used to watch for file system changes? A) fs.watchFile B) fs.monitor C) fs.observe

Ultimate Exam

D) fs.track Answer: A Explanation: fs.watchFile (and fs.watch) allow you to listen for changes to a file or directory. Question 25. In an Express.js error-handling middleware, what must be the signature of the function? A) (err, req, res, next) B) (req, res, next, err) C) (req, res, err) D) (error, request, response) Answer: A Explanation: Error-handling middleware has four parameters, with the first being the error object. Question 26. Which of the following is the correct way to import a JSON file using ES module syntax? A) import data from './data.json' assert { type: 'json' }; B) import data from './data.json'; C) import * as data from './data.json'; D) import data = require('./data.json'); Answer: A Explanation: As of Node.js v17+, importing JSON with ES modules requires the assert { type: 'json' } syntax. Question 27. Which method of a Readable stream will cause it to emit a 'data' event automatically? A) stream.pause() B) stream.resume() C) stream.pipe() D) stream.unpipe() Answer: B Explanation: Calling stream.resume() switches the stream into flowing mode, causing 'data' events to be emitted.

Ultimate Exam

B) res.setHeader('Set-Cookie', 'session=abc123; Expires=1h'); C) res.addCookie('session', 'abc123', 3600); D) res.cookie('session', 'abc123', { expires: new Date(Date.now() + 3600) }); Answer: A Explanation: maxAge is specified in milliseconds; 3600000 ms equals one hour. Question 32. Which Node.js function can be used to retrieve the current high-resolution real time in nanoseconds? A) process.hrtime.bigint() B) Date.now() C) process.uptime() D) performance.now() Answer: A Explanation: process.hrtime.bigint() returns a bigint representing nanoseconds since an arbitrary time, useful for precise timing. Question 33. What will the following code output?

(async () => { console.log(1); await Promise.resolve(); console.log(2); })(); console.log(3);

A) 1 2 3 B) 1 3 2 C) 3 1 2 D) 3 2 1 Answer: B Explanation: The async IIFE runs synchronously until the first await. It logs 1, then yields. The outer script logs 3. After the resolved promise, it logs 2.

Ultimate Exam

Question 34. Which of the following statements about Node.js worker threads is TRUE? A) They share the same event loop as the main thread. B) They can share memory using SharedArrayBuffer. C) They cannot import modules. D) They are only available on Windows platforms. Answer: B Explanation: Worker threads run in separate V8 isolates but can share memory via SharedArrayBuffer and Atomics. Question 35. Which environment variable can be used to set the maximum number of concurrent HTTP connections in Node.js? A) NODE_MAX_CONNECTIONS B) HTTP_MAX_CONNECTIONS C) MAX_CONNECTIONS D) None; it is set programmatically Answer: D Explanation: Node.js does not provide a specific environment variable for this; you set it via http.globalAgent.maxSockets or similar APIs. Question 36. In a package.json script, what does the && operator do? A) Runs two commands in parallel. B) Executes the second command only if the first succeeds. C) Redirects output to a file. D) Ignores errors from the first command. Answer: B Explanation: && is a shell operator that runs the next command only if the preceding command exits with a zero status. Question 37. Which of the following is the correct way to handle a rejected promise using async/await? A) await promise.catch(err => console.error(err));

Ultimate Exam

Answer: B Explanation: The Accept header lists MIME types that the client can process. Question 41. In Node.js, which of the following is the correct way to create a TCP server using the net module? A) net.createServer((socket) => { /* … */ }).listen(8080); B) net.listen(8080, (socket) => { /* … */ }); C) net.tcpServer(8080, handler); D) net.createTcpServer(handler).listen(8080); Answer: A Explanation: net.createServer returns a Server object that can be instructed to listen on a port. Question 42. What is the default value of process.argv[0] when a Node.js script is executed? A) The absolute path to the Node.js executable. B) The name of the script file. C) The current working directory. D) undefined Answer: A Explanation: process.argv[0] contains the path to the Node.js binary; process.argv[1] holds the script path. Question 43. Which of the following statements about the URL class in Node.js is correct? A) It can parse only HTTP URLs. B) It automatically resolves relative paths against the current working directory. C) It provides properties like pathname, searchParams, and hostname. D) It is only available when using the url module with CommonJS. Answer: C Explanation: The URL class (global in recent Node versions) offers granular access to URL components.

Ultimate Exam

Question 44. In Express.js, which method is used to serve static files from the directory public? A) app.use(express.static('public')) B) app.static('public') C) app.serve('public') D) app.get('/static', express.static('public')) Answer: A Explanation: express.static middleware serves files relative to the given root directory. Question 45. Which of the following is a valid way to set a timeout for an HTTP request using the native http module? A) req.setTimeout(5000); B) http.timeout = 5000; C) options.timeout = 5000; passed to http.request D) Both A and C Answer: D Explanation: You can call req.setTimeout on the request object or provide a timeout property in the options object. Question 46. Which of the following is true about Node.js's global object? A) It is automatically exported by all modules. B) Properties added to global become available in every module without requiring them. C) It is equivalent to window in browsers. D) It can be reassigned to a different object. Answer: B Explanation: Adding a property to global makes it globally accessible, similar to a truly global variable. Question 47. What does the npm audit command do? A) Installs the latest version of all dependencies. B) Scans the dependency tree for known security vulnerabilities.

Ultimate Exam

Explanation: The 'drain' event signals that the stream can accept more data after the buffer has been flushed. Question 51. Which of these is the correct syntax to import a named export foo from a module utils.mjs using ES modules? A) import foo from './utils.mjs'; B) import { foo } from './utils.mjs'; C) const { foo } = require('./utils.mjs'); D) import * as foo from './utils.mjs'; Answer: B Explanation: Named imports use curly braces. Question 52. What does the --trace-warnings flag do when starting a Node.js process? A) It logs stack traces for all emitted warnings. B) It disables all warnings. C) It prints memory usage on each warning. D) It treats warnings as errors. Answer: A Explanation: The flag adds a stack trace to warning messages, aiding debugging. Question 53. Which of the following correctly disables the X-Powered-By header in an Express app? A) app.disable('x-powered-by'); B) app.set('x-powered-by', false); C) app.use((req, res, next) => { res.removeHeader('X-Powered-By'); next(); }); D) All of the above Answer: D Explanation: All three approaches prevent the header from being sent. Question 54. In an HTTP/2 server created with the http2 module, which method is used to create a secure server? A) http2.createSecureServer(options, handler)

Ultimate Exam

B) http2.createServer(options, handler) C) http2.createHttpsServer(options, handler) D) http2.createTLS(options, handler) Answer: A Explanation: http2.createSecureServer sets up an HTTP/2 server over TLS. Question 55. Which of the following is the correct way to listen for uncaught promise rejections globally? A) process.on('unhandledRejection', handler) B) process.on('uncaughtException', handler) C) process.on('rejectionHandled', handler) D) process.on('promiseError', handler) Answer: A Explanation: The 'unhandledRejection' event is emitted when a promise is rejected and no .catch handler is attached. Question 56. Which of the following statements about the Node.js crypto module’s randomBytes function is true? A) It returns a string by default. B) It is cryptographically secure. C) It blocks the event loop for large inputs. D) It can only generate up to 256 bytes. Answer: B Explanation: crypto.randomBytes produces cryptographically strong pseudo-random data. Question 57. What is the effect of setting NODE_ENV=production when running an Express app? A) Express automatically enables view caching and disables stack traces. B) Node.js disables all console output. C) The app runs in a sandboxed environment. D) It forces HTTP/2 usage. Answer: A

Ultimate Exam

A)

new Promise((res, rej) => setTimeout(() => rej(new Error('Timeout')), 5000));

B) Promise.timeout(5000) C) await Promise.race([myPromise, Promise.delay(5000)]) D) myPromise.timeout(5000) Answer: A Explanation: Creating a new promise that rejects after a setTimeout implements a manual timeout. Question 62. Which of the following is the default port for an Express server if no port is specified? A) 80 B) 3000 C) 8080 D) 5000 Answer: B Explanation: Many tutorials start Express on port 3000, but the framework itself does not enforce a default; however, the commonly used convention is 3000. (Assuming the exam expects 3000.) Question 63. What does the --inspect flag enable when starting a Node.js process? A) Automatic code linting. B) Debugging via the Chrome DevTools protocol. C) Production mode optimizations. D) Real-time code compilation. Answer: B Explanation: --inspect opens a debugging port that can be attached to by Chrome DevTools or other inspectors. Question 64. In a Node.js REPL, which command returns the current history of entered commands?

Ultimate Exam

A) .history B) .list C) .show D) .commands Answer: A Explanation: .history displays the REPL command history. Question 65. Which of the following correctly creates a TCP client that connects to localhost on port 4000? A)

const client = net.createConnection({ host: 'localhost', port: 4000 });

B) net.connect(4000, 'localhost') C) Both A and B D) Neither A nor B Answer: C Explanation: Both net.createConnection with an options object and net.connect with arguments achieve the same result. Question 66. Which of the following statements about process.nextTick and setImmediate is correct? A) setImmediate callbacks always run before process.nextTick. B) process.nextTick callbacks run after I/O events. C) process.nextTick callbacks are executed before the event loop continues to the next phase. D) Both are executed in the same phase of the event loop. Answer: C Explanation: process.nextTick callbacks are processed immediately after the current operation, before the event loop proceeds. Question 67. Which of the following is the correct way to create a simple HTTP server that responds with “Hello World” using the http module?