[JSNAD] OpenJS Node js Application Developer JSNAD Certification Exam Guide, Exams of Technology

A comprehensive developer-focused guide covering Node.js application development, asynchronous programming, package management, debugging techniques, and performance optimization. Includes coding-focused practice questions, technical explanations, and exam-aligned exercises for developers preparing for certification.

Typology: Exams

2025/2026

Available from 02/18/2026

shilpi-jain-3
shilpi-jain-3 🇮🇳

2.5

(11)

80K documents

1 / 83

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
[JSNAD] OpenJS Node js Application Developer
JSNAD Certification Exam Guide
**Question 1.** Which method should be used to create a Buffer of a specific size that is zerofilled?
A) Buffer.allocUnsafe()
B) Buffer.from()
C) Buffer.alloc()
D) new Buffer()
Answer: C
Explanation: Buffer.alloc(size) creates a buffer of the given size and fills it with zeros, providing safe
initialization.
**Question 2.** What is the primary risk of using Buffer.allocUnsafe()?
A) It creates readonly buffers.
B) It may contain old, sensitive data.
C) It throws an exception for large sizes.
D) It automatically converts to UTF8.
Answer: B
Explanation: allocUnsafe allocates memory without zerofilling, so the buffer may contain leftover data
from previous allocations, posing a security risk.
**Question 3.** Which encoding is NOT natively supported by Buffer.toString()?
A) utf8
B) ascii
C) base64url
D) hex
Answer: C
Explanation: Buffer supports utf8, ascii, base64, hex, etc., but “base64url” is not a builtin encoding; you
must manually replace characters.
**Question 4.** To convert a string “hello” into a Buffer using UTF8, which call is correct?
A) Buffer.from('hello', 'utf8')
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

Partial preview of the text

Download [JSNAD] OpenJS Node js Application Developer JSNAD Certification Exam Guide and more Exams Technology in PDF only on Docsity!

JSNAD Certification Exam Guide

Question 1. Which method should be used to create a Buffer of a specific size that is zero‑filled? A) Buffer.allocUnsafe() B) Buffer.from() C) Buffer.alloc() D) new Buffer() Answer: C Explanation: Buffer.alloc(size) creates a buffer of the given size and fills it with zeros, providing safe initialization. Question 2. What is the primary risk of using Buffer.allocUnsafe()? A) It creates read‑only buffers. B) It may contain old, sensitive data. C) It throws an exception for large sizes. D) It automatically converts to UTF‑8. Answer: B Explanation: allocUnsafe allocates memory without zero‑filling, so the buffer may contain leftover data from previous allocations, posing a security risk. Question 3. Which encoding is NOT natively supported by Buffer.toString()? A) utf B) ascii C) base64url D) hex Answer: C Explanation: Buffer supports utf8, ascii, base64, hex, etc., but “base64url” is not a built‑in encoding; you must manually replace characters. Question 4. To convert a string “hello” into a Buffer using UTF‑8, which call is correct? A) Buffer.from('hello', 'utf8')

JSNAD Certification Exam Guide

B) Buffer.alloc('hello') C) Buffer.from('hello', 'hex') D) new Buffer('hello') Answer: A Explanation: Buffer.from(string, encoding) creates a buffer from the string using the specified encoding; default is utf8. Question 5. Which of the following stream types can both read and write data? A) Readable B) Writable C) Duplex D) Transform Answer: C Explanation: Duplex streams implement both Readable and Writable interfaces, allowing bidirectional data flow. Question 6. In the context of Node streams, what does “backpressure” refer to? A) The speed at which data is compressed. B) The mechanism that prevents a fast source from overwhelming a slow destination. C) The default buffer size of a Transform stream. D) The amount of memory allocated for a Buffer. Answer: B Explanation: Backpressure is the flow‑control signal that tells a readable source to slow down when the writable destination cannot keep up. Question 7. Which API automatically destroys all streams on error, simplifying error handling? A) stream.pipe() B) stream.pipeline() C) stream.concat()

JSNAD Certification Exam Guide

Answer: B Explanation: process.nextTick queues a callback to execute immediately after the current operation, before the event loop continues, while setImmediate schedules execution after I/O events in the check phase. Question 11. Which pattern describes a Node.js callback that receives an error as its first argument? A) Promise‑first callback B) Error‑first callback C) Async‑first callback D) Callback‑only pattern Answer: B Explanation: The error‑first callback convention passes an error object as the first argument, followed by result data. Question 12. How can you convert a function that uses an error‑first callback into a Promise? A) Wrap it with util.promisify() B) Use new Promise() and call the function inside C) Both A and B are valid D) It cannot be converted Answer: C Explanation: You can either manually wrap the function in a new Promise or use util.promisify to automatically create a promisified version. Question 13. Which Promise method resolves when all promises have settled, regardless of rejection or fulfillment? A) Promise.all() B) Promise.race() C) Promise.allSettled() D) Promise.any()

JSNAD Certification Exam Guide

Answer: C Explanation: Promise.allSettled returns a promise that resolves after every input promise has either fulfilled or rejected, providing their status. Question 14. If you need the result of the fastest‑fulfilling promise but want to ignore rejections, which method should you use? A) Promise.race() B) Promise.any() C) Promise.all() D) Promise.allSettled() Answer: B Explanation: Promise.any resolves with the first fulfilled promise and rejects only if all promises reject. Question 15. Which event is emitted when an unhandled promise rejection occurs in a Node process? A) uncaughtException B) unhandledRejection C) rejectionHandled D) promiseError Answer: B Explanation: The unhandledRejection event is emitted on the process object when a promise is rejected and no rejection handler is attached. Question 16. Which fs method reads a file synchronously? A) fs.readFile() B) fs.readFileSync() C) fs.promises.readFile() D) fs.createReadStream() Answer: B

JSNAD Certification Exam Guide

Question 20. Which method of the URL class returns the query string as an object? A) url.searchParams B) url.query C) url.getParams() D) url.parse() Answer: A Explanation: url.searchParams provides a URLSearchParams object that can be iterated or converted to an object for query parameters. Question 21. To retrieve the current working directory of a Node process, you use: A) process.cwd() B) process.env.PWD C) __dirname D) global.cwd() Answer: A Explanation: process.cwd() returns the absolute path of the directory from which the Node process was launched. Question 22. Which property of process contains the command‑line arguments passed to the script? A) process.argv B) process.args C) process.argv D) process.parameters Answer: C Explanation: process.argv is an array where the first two elements are the node executable and script path, followed by any additional arguments.

JSNAD Certification Exam Guide

Question 23. How can you safely access an environment variable named PORT with a fallback of 3000? A) process.env.PORT || 3000 B) process.getEnv('PORT', 3000) C) process.env['PORT'] ?? 3000 D) Both A and C are valid Answer: D Explanation: Both the logical OR (||) and nullish coalescing (??) operators can provide a default value when process.env.PORT is undefined or empty. Question 24. Which os module method returns the total amount of system memory in bytes? A) os.totalmem() B) os.freemem() C) os.memoryUsage() D) os.getTotalMemory() Answer: A Explanation: os.totalmem() reports the total system memory, whereas os.freemem() reports the amount currently free. Question 25. What does Object.create(null) produce? A) An object with the default Object prototype. B) An object with no prototype, thus no inherited properties. C) A shallow copy of the global object. D) A frozen object. Answer: B Explanation: Passing null as the prototype creates a plain dictionary object without the default Object.prototype methods. Question 26. Which syntax correctly defines a class that inherits from a base class Animal?

JSNAD Certification Exam Guide

B) filter() C) reduce() D) find() Answer: B Explanation: filter iterates over each element and includes it in the result array if the callback returns a truthy value. Question 30. What does the reduce method return when called on an empty array without an initial value? A) undefined B) null C) Throws a TypeError D) 0 Answer: C Explanation: Without an initial accumulator, reduce throws a TypeError when the array is empty because there is no value to start the reduction. Question 31. Which statement correctly imports the fs module using CommonJS syntax? A) import fs from 'fs'; B) const fs = require('fs'); C) const { fs } = require('fs'); D) import * as fs from 'fs'; Answer: B Explanation: CommonJS uses require to load modules; import is part of ES modules. Question 32. How can you enable ES Module support for a file named app.js without changing the file extension? A) Add "type": "module" to package.json. B) Use require('app') instead of import.

JSNAD Certification Exam Guide

C) Rename the file to app.mjs. D) Use the --esm flag when running Node. Answer: A Explanation: Setting "type": "module" in package.json tells Node to treat .js files as ES modules. Question 33. Which of the following statements about interoperability between CommonJS and ESM is correct? A) An ES module can require a CommonJS module using import. B) A CommonJS module can import an ES module using require only if the ES module has a default export. C) An ES module can import a CommonJS module using import with the default property. D) Interoperability is not possible; they must be separate. Answer: C Explanation: When importing a CommonJS module via import, Node creates a synthetic default export that contains the CommonJS module.exports object. Question 34. Which command adds a package as a development dependency? A) npm install lodash --save-dev B) npm install lodash --prod C) npm add lodash --dev D) npm install lodash - D Answer: A (and D is also correct) Explanation: --save-dev or its shorthand -D records the package under devDependencies in package.json. Question 35. In semantic versioning, what does a version number 2.5.0 indicate? A) Major version 2, minor version 5, patch 0 – backward compatible changes introduced. B) Minor version 2, major version 5, patch 0 – breaking changes. C) Patch version 2, minor version 5, major 0 – bug fixes only.

JSNAD Certification Exam Guide

Explanation: spawn returns a ChildProcess object with streams for stdio, allowing real‑time data handling. Question 39. Which method should be used to run a command synchronously, blocking the event loop until completion? A) spawnSync() B) execSync() C) forkSync() D) Both A and B are valid, depending on needs Answer: D Explanation: Both spawnSync and execSync provide synchronous execution; spawnSync streams data, while execSync buffers output. Question 40. When using child_process.fork(), what IPC channel is automatically established? A) A TCP socket B) A UNIX domain socket C) A message channel using process.send() and process.on('message') D) No channel; you must create one manually Answer: C Explanation: fork creates a new Node.js process with an established IPC channel for sending JSON‑serializable messages. Question 41. Which built‑in Node module provides the assert function for simple testing? A) test B) assert C) chai D) expect Answer: B Explanation: The assert module is part of Node’s core library and offers a collection of assertion functions.

JSNAD Certification Exam Guide

Question 42. Which command starts Node’s experimental built‑in test runner introduced in Node 18? A) node test.js B) node --test C) node --inspect test.js D) npm test Answer: B Explanation: node --test launches the built‑in test runner that discovers and runs test files. Question 43. To debug a Node application using Chrome DevTools, which flag should you include when starting the process? A) --inspect-brk B) --debug C) --trace-warnings D) --prof Answer: A Explanation: --inspect-brk starts the inspector and pauses execution at the first line, allowing Chrome DevTools to attach. Question 44. Which console method prints a stack trace along with the message? A) console.log() B) console.info() C) console.warn() D) console.trace() Answer: D Explanation: console.trace outputs a stack trace to help locate where the call originated.

JSNAD Certification Exam Guide

A) The maximum number of listeners. B) The size (in bytes or objects) at which the internal buffer will pause reading. C) The timeout for stream operations. D) The priority of the stream in the event loop. Answer: B Explanation: highWaterMark defines the threshold at which a stream’s internal buffer is considered full, triggering backpressure. Question 49. Which method of the fs module returns a Promise that resolves with file statistics? A) fs.stat() B) fs.promises.stat() C) fs.lstatSync() D) fs.getStats() Answer: B Explanation: fs.promises.stat is the promise‑based version of fs.stat. Question 50. Which path method resolves a sequence of paths to an absolute path? A) path.normalize() B) path.resolve() C) path.join() D) path.isAbsolute() Answer: B Explanation: path.resolve processes the arguments from right to left, building an absolute path. Question 51. When constructing a URL with the URL constructor, which of the following is the correct syntax? A) new URL('https://example.com', 'api') B) new URL('api', 'https://example.com') C) new URL('https://example.com/api')

JSNAD Certification Exam Guide

D) URL('https://example.com') Answer: C Explanation: The URL constructor takes a full URL string; the optional second argument is a base URL for relative URLs. Question 52. Which environment variable is automatically set by Node to indicate the current working directory? A) NODE_PATH B) PWD C) HOME D) NODE_CWD Answer: B Explanation: On Unix‑like systems, process.env.PWD reflects the directory from which Node was launched. Question 53. Which os method returns an array of objects describing each CPU core? A) os.cpus() B) os.cpuInfo() C) os.getCores() D) os.processors() Answer: A Explanation: os.cpus() provides details such as model, speed, and times for each logical CPU core. Question 54. In JavaScript, which of the following creates a closure that captures the loop variable correctly? A) for (var i=0;i<5;i++) { setTimeout(() => console.log(i), 0); } B) for (let i=0;i<5;i++) { setTimeout(() => console.log(i), 0); } C) for (var i=0;i<5;i++) { (function(i){ setTimeout(() => console.log(i),0); })(i); } D) Both B and C are correct.

JSNAD Certification Exam Guide

Explanation: The import assertions syntax (assert { type: 'json' }) tells Node to treat the imported file as JSON. Question 58. Which npm command installs a package and updates the package-lock.json file accordingly? A) npm install lodash --no-save B) npm i lodash --save-dev C) npm add lodash --save D) npm install lodash --package-lock-only Answer: B Explanation: npm install (or npm i) adds the package and updates both package.json and package- lock.json; --save-dev marks it as a dev dependency. Question 59. Which of the following is the correct way to emit a custom event named ready with data {status: 'ok'}? A) emitter.emit('ready', {status: 'ok'}); B) emitter.raise('ready', {status: 'ok'}); C) emitter.trigger('ready', {status: 'ok'}); D) emitter.publish('ready', {status: 'ok'}); Answer: A Explanation: emit is the standard method on EventEmitter to dispatch events with optional arguments. Question 60. In a child process created with exec, how is the command’s standard output accessed? A) child.stdout B) child.stdio[1] C) The callback’s stdout argument D) child.output[1] Answer: C Explanation: exec buffers the output and provides it via the callback’s second argument (stdout).

JSNAD Certification Exam Guide

Question 61. Which of the following statements about process.nextTick is FALSE? A) It runs before any I/O callbacks. B) It can cause starvation of the event loop if overused. C) It executes after the current call stack but before the next tick. D) It is part of the poll phase. Answer: D Explanation: process.nextTick callbacks are executed immediately after the current operation, not as part of the poll phase. Question 62. Which method of the fs module can be used to atomically replace a file’s contents? A) fs.rename() B) fs.copyFile() C) fs.writeFile() with the wx flag D) fs.truncate() Answer: C Explanation: Using the wx flag ('w' for write, 'x' for exclusive) ensures the file is created only if it does not already exist, providing atomicity when combined with a temporary file rename. Question 63. Which of the following correctly creates a readable stream that transforms incoming data to uppercase? A) const { Transform } = require('stream'); const upper = new Transform({ transform(chunk, enc, cb){ cb(null, chunk.toString().toUpperCase()); } }); B) const upper = new Transform({ write(chunk){ this.push(chunk.toString().toUpperCase()); } }); C) const upper = new Transform({ read(size){ } }); D) const upper = new Transform(); upper.on('data', d=> d.toUpperCase()); Answer: A Explanation: Implementing _transform (named transform in the options) is required; the callback must receive the transformed chunk.