JSNAD OpenJS Node js Application Developer Practice Exam, Exams of Technology

A coding-intensive exam that simulates real Node.js application development tasks. Candidates build modules, manage asynchronous operations, handle file system tasks, work with buffers/streams, design REST APIs, manage npm packages, and troubleshoot runtime errors. It also covers debugging, event loop mechanics, error handling, and performance tuning.

Typology: Exams

2025/2026

Available from 01/11/2026

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 113

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
JSNAD OpenJS Node js Application
Developer Practice Exam
**Question 1. Which Node.js utility converts a callbackbased function into one that returns a
Promise?**
A) util.promisify()
B) util.callbackify()
C) util.depromisify()
D) util.convert()
Answer: A
Explanation: `util.promisify()` takes a function following the errorfirst callback style and returns
a version that returns a Promise.
**Question 2. What is the order of execution for the following functions in a Node.js script?
`process.nextTick`, `setImmediate`, `setTimeout(...,0)`**
A) nextTick → setTimeout → setImmediate
B) setTimeout → nextTick → setImmediate
C) nextTick → setImmediate → setTimeout
D) setImmediate → nextTick → setTimeout
Answer: A
Explanation: `process.nextTick` callbacks run before the eventloop proceeds to the timers
phase, `setTimeout(...,0)` runs in the timers phase, and `setImmediate` runs in the check phase
after I/O callbacks.
**Question 3. Which method of a Promise is guaranteed to run regardless of whether the
Promise was fulfilled or rejected?**
A) .then()
B) .catch()
C) .finally()
D) .always()
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
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download JSNAD OpenJS Node js Application Developer Practice Exam and more Exams Technology in PDF only on Docsity!

Developer Practice Exam

Question 1. Which Node.js utility converts a callback‑based function into one that returns a Promise? A) util.promisify() B) util.callbackify() C) util.depromisify() D) util.convert() Answer: A Explanation: util.promisify() takes a function following the error‑first callback style and returns a version that returns a Promise. Question 2. What is the order of execution for the following functions in a Node.js script? process.nextTick, setImmediate, setTimeout(...,0) A) nextTick → setTimeout → setImmediate B) setTimeout → nextTick → setImmediate C) nextTick → setImmediate → setTimeout D) setImmediate → nextTick → setTimeout Answer: A Explanation: process.nextTick callbacks run before the event‑loop proceeds to the timers phase, setTimeout(...,0) runs in the timers phase, and setImmediate runs in the check phase after I/O callbacks. Question 3. Which method of a Promise is guaranteed to run regardless of whether the Promise was fulfilled or rejected? A) .then() B) .catch() C) .finally() D) .always()

Developer Practice Exam

Answer: C Explanation: .finally() is invoked after the Promise settles, no matter the outcome. Question 4. In a stream pipeline, which event indicates that the source Readable stream has no more data to provide? A) 'end' B) 'close' C) 'finish' D) 'error' Answer: A Explanation: The 'end' event is emitted by a Readable stream when it has pushed all data and will not emit more. Question 5. Which of the following Buffer methods creates a new Buffer containing the same bytes as the original? A) buf.slice() B) buf.copy() C) Buffer.from(buf) D) buf.clone() Answer: C Explanation: Buffer.from(buf) creates a new Buffer with a copy of the bytes; slice returns a view, not a copy. Question 6. What does the highWaterMark option control in a Writable stream? A) Maximum size of each chunk written B) Number of listeners allowed

Developer Practice Exam

A) .on() B) .once() C) .addListener() D) .prependListener() Answer: B Explanation: .once() automatically removes the listener after the first invocation. Question 10. When extending EventEmitter in a custom class, which line correctly sets up inheritance in ES6 syntax? A) class MyEmitter extends EventEmitter {} B) MyEmitter.prototype = new EventEmitter(); C) util.inherit(MyEmitter, EventEmitter); D) Object.setPrototypeOf(MyEmitter, EventEmitter); Answer: A Explanation: Using class MyEmitter extends EventEmitter properly inherits EventEmitter behavior. Question 11. What is the result of require('./config') if config.js contains module.exports = { port: 3000 };? A) { port: 3000 } B) [Function: config] C) undefined D) null Answer: A Explanation: module.exports is the value returned by require.

Developer Practice Exam

Question 12. Which of the following statements about module caching in Node.js is correct? A) Each require call loads the module anew. B) Modules are cached after the first successful load. C) Cache can be disabled with a flag. D) Only core modules are cached. Answer: B Explanation: After a module is loaded, Node stores it in require.cache; subsequent requires return the cached instance. Question 13. Which syntax correctly imports the default export from an ES module named utils.mjs? A) const utils = require('./utils.mjs'); B) import utils from './utils.mjs'; C) import * as utils from './utils.mjs'; D) const { default: utils } = require('./utils.mjs'); Answer: B Explanation: import utils from './utils.mjs' imports the default export; require cannot load ES modules without a loader. Question 14. In an async function, how can you catch errors thrown by an awaited Promise without using try/catch? A) Append .catch() to the awaited call. B) Use await Promise.handleError(). C) Wrap the call in process.on('unhandledRejection'). D) Errors cannot be caught without try/catch.

Developer Practice Exam

B) execFile() C) spawn() D) fork() Answer: C Explanation: spawn returns streams for stdin/stdout/stderr, allowing efficient handling of large data. Question 18. When using child_process.fork, how can the parent process send a message to the child? A) child.send(message) B) child.write(message) C) process.emit('message', message) D) child.postMessage(message) Answer: A Explanation: fork creates a Node.js process with an IPC channel; child.send() transmits a serializable message. Question 19. Which os module method returns the total system memory in bytes? A) os.totalmem() B) os.freemem() C) os.memory() D) os.sysmem() Answer: A Explanation: os.totalmem() provides the total amount of system memory. Question 20. What does the --inspect flag do when starting a Node.js process?

Developer Practice Exam

A) Enables the built‑in debugger protocol on a WebSocket. B) Prints the AST of the script. C) Forces strict mode. D) Disables all console output. Answer: A Explanation: --inspect opens the V8 inspector, allowing tools like Chrome DevTools to connect. Question 21. Which of the following statements about process.nextTick is true? A) It executes after I/O callbacks. B) It runs before the event loop proceeds to the next phase. C) It is deprecated in Node 12+. D) It can only be called once per tick. Answer: B Explanation: process.nextTick callbacks are processed immediately after the current operation, before the event loop continues. Question 22. In a Transform stream, which method must be implemented to modify incoming data? A) _read() B) _write() C) _transform(chunk, encoding, callback) D) _flush(callback) Answer: C Explanation: _transform receives each chunk, processes it, and pushes the transformed data.

Developer Practice Exam

Explanation: process.on('uncaughtException') registers a listener for exceptions not caught elsewhere. Question 26. What does the --check (or -c) Node flag do? A) Executes the file in strict mode. B) Checks syntax without running the script. C) Compiles the script to bytecode. D) Starts the REPL. Answer: B Explanation: --check parses the file for syntax errors but does not execute it. Question 27. Which statement about let and var is correct? A) Both are hoisted to the top of the block. B) let declarations are not hoisted. C) var is block‑scoped, let is function‑scoped. D) let creates a block‑scoped binding; var creates a function‑scoped binding. Answer: D Explanation: let respects block scope, while var is scoped to the nearest function. Question 28. In arrow functions, how is this determined? A) It is bound to the object that calls the function. B) It is lexically inherited from the surrounding scope. C) It defaults to the global object. D) Arrow functions have their own this. Answer: B

Developer Practice Exam

Explanation: Arrow functions do not have their own this; they capture the this value of the enclosing lexical context. Question 29. Which assert method checks deep equality of two objects? A) assert.equal() B) assert.strictEqual() C) assert.deepStrictEqual() D) assert.deepEqual() (deprecated) Answer: C Explanation: assert.deepStrictEqual() verifies that objects have the same structure and values, using strict equality. Question 30. What does the npm install --save-dev command do? A) Adds the package to dependencies. B) Adds the package to devDependencies. C) Installs globally. D) Installs without updating package.json. Answer: B Explanation: --save-dev records the package under devDependencies in package.json. Question 31. Which of the following is NOT a valid HTTP method that can be sent using Node’s http.request? A) GET B) POST C) FETCH D) DELETE

Developer Practice Exam

D) Manages process exit codes. Answer: B Explanation: process.env provides access to the operating system’s environment variables. Question 35. Which of the following statements about Promise.race is true? A) It resolves when all promises have resolved. B) It resolves or rejects as soon as the first promise settles. C) It returns an array of results. D) It never rejects. Answer: B Explanation: Promise.race settles with the outcome of the first promise that settles, whether fulfilled or rejected. Question 36. In a Node.js REPL, which command clears the console screen? A) .clear B) .cls C) .clear() D) .clearScreen Answer: A Explanation: .clear is a REPL command that clears the console. Question 37. Which of the following is the correct way to read from process.stdin using async/await? A) const data = await process.stdin.read(); B) const chunks = []; for await (const chunk of process.stdin) { chunks.push(chunk); }

Developer Practice Exam

C) process.stdin.on('data', async (d) => await d); D) await process.stdin.once('data'); Answer: B Explanation: process.stdin is an async iterable; using for await...of collects the data. Question 38. What does the os.platform() function return? A) The OS version string. B) The CPU architecture. C) The operating system identifier (e.g., 'win32', 'linux'). D) The hostname. Answer: C Explanation: os.platform() returns a string identifying the OS platform. Question 39. Which of these npm scripts runs node server.js when you type npm start? A) "scripts": { "start": "node server.js" } B) "scripts": { "run": "node server.js" } C) "scripts": { "serve": "node server.js" } D) "scripts": { "init": "node server.js" } Answer: A Explanation: The start script is executed by npm start. Question 40. Which of the following is true about the Node.js cluster module? A) It creates child processes that share the same event loop. B) It allows multiple Node.js processes to share a server port. C) It is only available on Windows.

Developer Practice Exam

A) 'utf8' B) 'ascii' C) null (returns a Buffer) D) 'base64' Answer: C Explanation: Without an encoding, fs.readFile returns a Buffer. Question 44. Which child_process method buffers the entire stdout and provides it via a callback? A) spawn() B) exec() C) execFile() with { stdio: 'pipe' } D) fork() Answer: B Explanation: exec collects stdout and stderr into strings and passes them to the callback. Question 45. Which of the following is a correct way to handle a rejected Promise using async/await? A) await promise; then check promise.error B) try { await promise; } catch (e) { /* handle */ } C) promise.then().catch(); only D) await promise.catch(); without try/catch Answer: B Explanation: Wrapping await in a try...catch captures rejections.

Developer Practice Exam

Question 46. How can you limit the number of concurrent async operations when using Promise.all? A) By passing a concurrency option to Promise.all. B) Use a third‑party library like p-limit or implement a queue. C) Promise.all automatically limits concurrency. D) Use await inside a for loop. Answer: B Explanation: Native Promise.all runs all promises concurrently; limiting requires custom logic or a library. Question 47. Which of the following is NOT a built‑in Node.js global object? A) Buffer B) process C) window D) console Answer: C Explanation: window is a browser global; Node provides global instead. Question 48. What does the path.parse('/home/user/file.txt') method return? A) An array of path segments. B) An object with root, dir, base, ext, name properties. C) A string with normalized path. D) A Buffer containing the path bytes. Answer: B Explanation: path.parse decomposes a path into its components.

Developer Practice Exam

Explanation: --no-warnings suppresses all process warnings, including deprecations. Question 52. What does process.exit(1) indicate? A) Successful termination. B) An error occurred; non‑zero exit code. C) The process will restart automatically. D) It signals the parent to ignore the exit. Answer: B Explanation: Exit code 0 means success; any non‑zero code (e.g., 1) signals failure. Question 53. Which of the following correctly creates a readable stream from a file? A) fs.createReadStream('file.txt') B) fs.readFileStream('file.txt') C) new Readable('file.txt') D) fs.openReadStream('file.txt') Answer: A Explanation: fs.createReadStream returns a Readable stream for the specified file. Question 54. In a Transform stream, which method should you call to pass processed data downstream? A) this.push(data) B) this.write(data) C) callback(null, data) D) this.emit('data', data) Answer: A

Developer Practice Exam

Explanation: Within _transform, after processing a chunk you call this.push() to enqueue the transformed data. Question 55. Which of the following statements about the EventEmitter max listeners limit is true? A) The default limit is 10 listeners per event. B) It cannot be changed. C) Exceeding the limit throws an error immediately. D) The limit applies to total listeners across all events. Answer: A Explanation: By default, Node warns when more than 10 listeners are added for a single event; it can be changed with setMaxListeners. Question 56. Which of these is a correct way to handle an error event on a Writable stream? A) stream.on('error', err => { /* handle */ }); B) stream.once('error', err => { /* handle */ }); only C) stream.emit('error', err); inside the stream implementation D) All of the above Answer: D Explanation: Both on and once can listen for 'error'; emitting 'error' is how a stream signals an error. Question 57. What does the fs.rm(path, { recursive: true }) method do? A) Deletes a file only. B) Recursively removes a directory and its contents.