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

Focuses on the creation and validation of JSNAD exam content. Candidates practice writing coding tasks, designing assessment rubrics, validating competency coverage, ensuring difficulty balance, verifying reliability of tasks, and maintaining exam integrity and accessibility.

Typology: Exams

2025/2026

Available from 01/11/2026

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

4.2

(5)

29K documents

1 / 101

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Exam Developer OpenJS Node js
Application Developer Practice Exam
**Question 1. Which method creates a Buffer of a specific size filled with zeros?**
A) Buffer.allocUnsafe()
B) Buffer.from()
C) Buffer.alloc()
D) new Buffer()
Answer: C
Explanation: Buffer.alloc(size) returns a zerofilled Buffer of the given size, guaranteeing no old
memory data is exposed.
**Question 2. What encoding does Buffer.from(string, 'base64') expect for the input string?**
A) UTF8
B) ASCII
C) Base64
D) Hexadecimal
Answer: C
Explanation: The second argument tells Buffer.from to interpret the input string as
Base64encoded data and decode it accordingly.
**Question 3. Which of the following statements about Buffer pooling is true?**
A) Buffers larger than 8 KB are always pooled.
B) Node reuses a shared memory pool for small Buffer allocations to improve performance.
C) Buffer pooling is disabled when using Buffer.alloc().
D) Buffer pooling only works on Windows platforms.
Answer: B
Explanation: For small buffers (≤ 8 KB), Node allocates them from a preallocated memory pool,
reducing the number of system calls.
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 Exam Developer OpenJS Node js Application Developer Practice Exam and more Exams Technology in PDF only on Docsity!

Application Developer Practice Exam

Question 1. Which method creates a Buffer of a specific size filled with zeros? A) Buffer.allocUnsafe() B) Buffer.from() C) Buffer.alloc() D) new Buffer() Answer: C Explanation: Buffer.alloc(size) returns a zero‑filled Buffer of the given size, guaranteeing no old memory data is exposed. Question 2. What encoding does Buffer.from(string, 'base64') expect for the input string? A) UTF‑ 8 B) ASCII C) Base D) Hexadecimal Answer: C Explanation: The second argument tells Buffer.from to interpret the input string as Base64‑encoded data and decode it accordingly. Question 3. Which of the following statements about Buffer pooling is true? A) Buffers larger than 8 KB are always pooled. B) Node reuses a shared memory pool for small Buffer allocations to improve performance. C) Buffer pooling is disabled when using Buffer.alloc(). D) Buffer pooling only works on Windows platforms. Answer: B Explanation: For small buffers (≤ 8 KB), Node allocates them from a pre‑allocated memory pool, reducing the number of system calls.

Application Developer Practice Exam

Question 4. When reading a large file in chunks using a readable stream, which event indicates that the stream has no more data to provide? A) 'data' B) 'end' C) 'close' D) 'finish' Answer: B Explanation: The 'end' event fires when the readable stream has emitted all its data and reaches EOF. Question 5. In a writable stream, what does the 'drain' event signify? A) The stream has finished writing all buffered data. B) The underlying file descriptor is closed. C) The internal buffer is empty and the stream is ready for more data. D) An error occurred during write. Answer: C Explanation: 'drain' is emitted when the write buffer empties, indicating that the stream can accept more data without backpressure. Question 6. Which method is used to transform data while it passes through a stream pipeline? A) stream.Transform() constructor B) stream.pipe() C) stream.concat() D) stream.map()

Application Developer Practice Exam

C) spawn can only run Node scripts, exec runs any command. D) spawn is synchronous, exec is asynchronous. Answer: B Explanation: spawn provides streams for stdin/stdout/stderr, suitable for large data; exec buffers the whole output and passes it to a callback. Question 10. Which child_process method should you use when you need inter‑process communication (IPC) between a parent and a Node child? A) spawn() B) exec() C) execFile() D) fork() Answer: D Explanation: fork() spawns a new Node process with an IPC channel, enabling message passing via process.send() and process.on('message'). Question 11. How can you pass an environment variable MY_VAR with value 123 to a spawned child process? A) child_process.spawn('cmd', [], { env: { MY_VAR: '123' } }) B) child_process.spawn('cmd', [], { env: process.env, MY_VAR: '123' }) C) child_process.spawn('cmd', [], { env: Object.assign({}, process.env, { MY_VAR: '123' }) }) D) child_process.spawn('cmd', [], { env: process.env.MY_VAR = '123' }) Answer: C Explanation: You must merge the existing environment with the new variable; Object.assign creates a new object containing both.

Application Developer Practice Exam

Question 12. Which EventEmitter method adds a listener that will be invoked only the first time the event is emitted? A) .on() B) .once() C) .addListener() D) .prependListener() Answer: B Explanation: .once(event, listener) registers a one‑time listener that is automatically removed after the first invocation. Question 13. What does EventEmitter.listenerCount(emitter, 'event') return? A) The number of times 'event' has been emitted. B) The number of listeners currently registered for 'event'. C) The total number of events the emitter can handle. D) The maximum allowed listeners for 'event'. Answer: B Explanation: listenerCount returns the current count of listeners attached to the specified event name. Question 14. Which of the following correctly removes a specific listener from an EventEmitter? A) emitter.removeAllListeners('data') B) emitter.off('data', listener) C) emitter.deleteListener('data', listener) D) emitter.unbind('data', listener) Answer: B

Application Developer Practice Exam

Answer: B Explanation: fs.stat() returns a Stats object containing information like size, birthtime, mode, etc. Question 18. Which of the following statements about let, const, and var is correct? A) const variables can be reassigned, but var cannot. B) var is block‑scoped, while let is function‑scoped. C) let and const are block‑scoped; var is function‑scoped. D) All three have the same hoisting behavior. Answer: C Explanation: let and const respect block boundaries; var is hoisted to the containing function or global scope. Question 19. What does the rest operator (...) do in a function parameter list? A) Spreads an array into separate arguments. B) Collects remaining arguments into an array. C) Creates a shallow copy of an object. D) Merges two objects. Answer: B Explanation: In a parameter list, ...args gathers all remaining positional arguments into an array named args. Question 20. Which syntax correctly uses destructuring to extract the property 'port' from an options object, providing a default of 3000? A) const { port = 3000 } = options; B) const [ port = 3000 ] = options;

Application Developer Practice Exam

C) const { port: 3000 } = options; D) const { port || 3000 } = options; Answer: A Explanation: Object destructuring with a default value uses the = syntax inside the braces. Question 21. In JavaScript, what is a closure? A) A function that calls itself recursively. B) A function that captures variables from its lexical scope even after that scope has finished executing. C) An immediately invoked function expression. D) A function that cannot access outer variables. Answer: B Explanation: A closure retains references to variables from the environment in which it was created. Question 22. Which of the following is true about prototype inheritance in ES6 class syntax? A) Classes do not use prototypes internally. B) The extends keyword creates a prototype chain between the subclass and superclass. C) Methods defined in a class are copied onto each instance. D) Superclass constructors are automatically called without super(). Answer: B Explanation: Using extends sets up the prototype chain so that the subclass inherits methods from the superclass. Question 23. How does the error‑first callback pattern indicate an error?

Application Developer Practice Exam

Question 26. Which signal is typically sent to a Node process to request a graceful shutdown? A) SIGKILL B) SIGSTOP C) SIGINT D) SIGUSR Answer: C Explanation: SIGINT (generated by Ctrl+C) is commonly intercepted to close resources and exit cleanly. Question 27. How can you retrieve the number of CPU cores available on the host machine using Node's os module? A) os.cpusCount() B) os.cpuCoreCount() C) os.cpus().length D) os.getCPUs() Answer: C Explanation: os.cpus() returns an array of CPU info objects; its length equals the number of logical cores. Question 28. Which property of process.env provides access to environment variables? A) process.environment B) process.env C) process.variables D) process.config

Application Developer Practice Exam

Answer: B Explanation: process.env is an object containing the current environment variables as key/value strings. Question 29. What does the Node.js inspector protocol allow you to do? A) Compile TypeScript on the fly. B) Debug JavaScript code remotely via Chrome DevTools or VS Code. C) Automatically generate unit tests. D) Encrypt network traffic. Answer: B Explanation: The inspector protocol enables remote debugging, profiling, and inspection of a running Node process. Question 30. Which built‑in module provides assertion functions for unit testing? A) test B) assert C) chai D) mocha Answer: B Explanation: The assert module offers simple assertion methods like assert.strictEqual, suitable for quick tests without external libraries. Question 31. In a package.json script, how would you run the file server.js with Node in production mode (NODE_ENV=production)? A) "start": "node server.js --env=production" B) "start": "NODE_ENV=production node server.js"

Application Developer Practice Exam

Question 34. Which of the following correctly creates a Transform stream that uppercases incoming text? A) new stream.Transform({ transform(chunk, enc, cb) { cb(null, chunk.toString().toUpperCase()); } }) B) new stream.Transform({ write(chunk, enc, cb) { this.push(chunk.toString().toUpperCase()); cb(); } }) C) new stream.Transform({ read(size) { this.push(this.read().toUpperCase()); } }) D) new stream.Transform({ process(chunk) { return chunk.toUpperCase(); } }) Answer: A Explanation: The transform method receives a chunk, processes it, and calls the callback with the transformed data. Question 35. When using async/await, which of the following is equivalent to: return fetch(url).then(r => r.json()); A) async function f(){ const r = await fetch(url); return r.json(); } B) async function f(){ const r = await fetch(url); await r.json(); } C) async function f(){ return await fetch(url).json(); } D) async function f(){ const r = fetch(url); return r.json(); } Answer: A Explanation: Await fetch, then call .json() (which returns a promise) and return it; the function itself returns a promise. **Question 36. What will the following code output?

process.nextTick(() => console.log('tick')); setImmediate(() => console.log('immediate')); console.log('sync'); ## Application Developer Practice Exam ## ```** A) sync, tick, immediate B) sync, immediate, tick C) tick, sync, immediate D) immediate, sync, tick Answer: A Explanation: Synchronous code runs first, then nextTick callbacks, then setImmediate callbacks. **Question 37. Which method of the child_process module returns a ChildProcess object that emits a 'message' event for IPC?** A) spawn() B) exec() C) fork() D) execFile() Answer: C Explanation: fork() creates a new Node process with an established IPC channel, enabling message events. **Question 38. In an EventEmitter, what does the method setMaxListeners(n) do?** A) Limits the number of times an event can be emitted. B) Sets the maximum number of listeners allowed for any single event before a warning is emitted. C) Removes all listeners after n emissions. D) Changes the order in which listeners are called. Answer: B ## Application Developer Practice Exam function foo(){ let a = 2; console.log(a); } foo(); console.log(a); ```** A) 2 2 B) 1 1 C) 2 1 D) 1 2 Answer: C Explanation: Inside foo, a is shadowed with value 2; outside, the outer a remains 1. **Question 42. Which of the following array methods does NOT create a new array?** A) map() B) filter() C) reduce() D) slice() Answer: C Explanation: reduce aggregates to a single value (or object) and does not return a new array unless explicitly done. **Question 43. In Node.js, what does the require.cache object store?** A) All exported values of loaded modules. B) The source code of each required module. C) The resolved filename to Module instance mapping for already loaded modules. D) Environment variables used by modules. ## Application Developer Practice Exam Answer: C Explanation: require.cache maps resolved module filenames to their Module objects, enabling caching and possible invalidation. **Question 44. Which of the following statements about ES6 modules (import/export) in Node.js is true as of Node 14+?** A) They can be used only with the .mjs extension or when "type": "module" is set in package.json. B) They replace CommonJS entirely. C) import statements are hoisted like require(). D) They cannot be used together with CommonJS in the same project. Answer: A Explanation: Node supports ES modules when files have .mjs extension or package.json specifies "type":"module". CommonJS still works. **Question 45. What does the following code print? ```js (async () => { console.log('A'); await Promise.resolve(); console.log('B'); })(); console.log('C'); ```** A) A C B B) C A B ## Application Developer Practice Exam **Question 48. Which of the following is NOT a valid way to handle an error emitted by a readable stream?** A) stream.on('error', handler) B) try { stream.read(); } catch(e) {} C) stream.once('error', handler) D) Using a pipeline with a callback that receives the error. Answer: B Explanation: Stream errors are emitted asynchronously; they cannot be caught with a synchronous try/catch around read(). **Question 49. What does the following code output? ```js const EventEmitter = require('events'); class My extends EventEmitter {} const m = new My(); m.emit('test'); ```** A) Throws an error because no listener is attached. B) No output; emitting an event without listeners does nothing. C) Returns true. D) Returns false. Answer: B Explanation: Emitting an event with no listeners is a no‑op; Node does not throw an error. **Question 50. Which of the following statements about Node's process.nextTick() vs setImmediate() is correct?** ## Application Developer Practice Exam A) nextTick callbacks are executed after I/O events, setImmediate before. B) nextTick runs before any I/O or timer callbacks; setImmediate runs after I/O callbacks. C) Both are equivalent and have the same execution order. D) setImmediate is only available on Windows. Answer: B Explanation: nextTick queues microtasks that run before the event loop proceeds to I/O; setImmediate runs in the check phase after I/O callbacks. **Question 51. What will the following code log? ```js console.log(typeof null); ```** A) 'null' B) 'object' C) 'undefined' D) 'number' Answer: B Explanation: In JavaScript, typeof null returns 'object' due to a historic bug. **Question 52. Which of the following is the correct way to create a shallow copy of an object using the spread operator?** A) const copy = {...original}; B) const copy = {...original, ...null}; C) const copy = {...original, ...original}; D) const copy = {...original, copy};