
































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The JSNADCN Exam is a region-specific version of the Node.js Application Developer exam, targeted for China. It validates practical, hands-on knowledge in developing server-side applications using Node.js. The exam covers core APIs, asynchronous programming, event loops, error handling, debugging, package management with npm, and working with file systems and streams. Localization ensures candidates in China can test under familiar conditions while aligning with international Node.js development standards.
Typology: Exams
1 / 72
This page cannot be seen from the preview
Don't miss anything!

































































Question 1. Which of the following is NOT a primitive data type in JavaScript? A) String B) Number C) Object D) Boolean Answer: C Explanation: Object is not a primitive data type; it is a reference type. Primitives include string, number, boolean, null, undefined, symbol, and bigint. Question 2. What does the let keyword provide in JavaScript that var does not? A) Hoisting B) Block scope C) Global scope D) Automatic type conversion Answer: B Explanation: let provides block scope, meaning the variable is only accessible within the block it was defined, unlike var which is function-scoped. Question 3. Which of the following is a correct way to declare a constant in ES6? A) constant PI = 3. B) const PI = 3. C) var PI = 3. D) let PI = 3. Answer: B Explanation: const is used to declare constants whose values cannot be reassigned. Question 4. Which operator is used to check both value and type in JavaScript? A) == B) =
Answer: C Explanation: The strict equality operator (===) checks both value and type. Question 5. What is the output of: console.log(typeof null)? A) 'null' B) 'object' C) 'undefined' D) 'number' Answer: B Explanation: typeof null returns 'object' due to a historical bug in JavaScript. Question 6. What will happen if you try to reassign a value to a const variable? A) It will silently fail B) It will throw a TypeError C) It will assign the value D) It will ignore the assignment Answer: B Explanation: Reassigning a const variable will throw a TypeError. Question 7. Which statement about arrow functions is true? A) They have their own 'this' context B) They inherit 'this' from the enclosing scope C) They are only available in ES D) They cannot be used as callback functions Answer: B Explanation: Arrow functions do not have their own 'this'; they inherit it from the enclosing lexical context.
C) await() D) catch() Answer: B Explanation: The then() method is used to handle the fulfillment of a Promise. Question 12. What does the async keyword do when used with a function? A) Makes the function asynchronous and always returns a Promise B) Makes the function synchronous C) Waits for a Promise to resolve D) Blocks all other code Answer: A Explanation: async makes the function return a Promise and allows the use of await within. Question 13. Which of the following is NOT a valid variable name in JavaScript? A) $var B) _var C) 2var D) var Answer: C Explanation: Variable names cannot start with a digit. Question 14. What is the result of: console.log('5' + 3)? A) 8 B) '53' C) '8' D) NaN Answer: B Explanation: The + operator concatenates when one operand is a string.
Question 15. Which of the following is used to import a module in CommonJS? A) import B) require C) include D) fetch Answer: B Explanation: CommonJS uses require() to import modules. Question 16. How do you export a function in a CommonJS module? A) export function myFunc() {} B) module.exports = myFunc; C) exports: myFunc D) require.myFunc = function() {} Answer: B Explanation: module.exports is used to export functions or objects in CommonJS. Question 17. What will happen if you require the same module twice in Node.js? A) It loads a new instance every time B) It caches the module after the first require C) It throws an error D) It overrides the previous one Answer: B Explanation: Node.js caches modules after the first load. Question 18. What is the default value of module.exports in Node.js? A) {} B) []
Question 22. Which command installs a module and adds it to dependencies in package.json? A) npm install
C) npm delete
C) CustomEmitter D) Emitter Answer: A Explanation: EventEmitter is the core class for events. Question 33. What module must be required to use EventEmitter? A) 'events' B) 'event' C) 'emitter' D) 'core' Answer: A Explanation: The 'events' module provides EventEmitter. Question 34. Which method removes a specific event listener? A) removeListener() B) remove() C) off() D) detach() Answer: A Explanation: removeListener() removes a listener for a given event. Question 35. What is the effect of calling removeAllListeners() on an EventEmitter? A) Removes all EventEmitters B) Removes all listeners for all events C) Removes only one listener D) Does nothing Answer: B Explanation: removeAllListeners() removes every listener for every event.
Question 36. Which event is emitted when an error occurs in EventEmitter? A) 'error' B) 'fail' C) 'exception' D) 'catch' Answer: A Explanation: The 'error' event is standard for errors. Question 37. What happens if an 'error' event is emitted with no listeners attached? A) It is ignored B) It throws an exception C) It logs a warning D) It stops the process Answer: B Explanation: If 'error' is emitted without a listener, Node.js throws and crashes. Question 38. How do you add a one-time event listener in EventEmitter? A) once() B) onetime() C) listenOnce() D) addOnce() Answer: A Explanation: once() attaches a listener that is invoked only once. Question 39. Which class is used for handling binary data in Node.js? A) Buffer B) Binary
Question 43. Which encoding is default for Buffer.toString()? A) hex B) base C) utf D) ascii Answer: C Explanation: utf8 is the default encoding for Buffer.toString(). Question 44. How do you concatenate two Buffer objects? A) Buffer.concat([buf1, buf2]) B) buf1 + buf C) buf1.concat(buf2) D) Buffer.join(buf1, buf2) Answer: A Explanation: Buffer.concat takes an array of Buffer objects. Question 45. Which stream type is used for writing data? A) Readable B) Writable C) Duplex D) Transform Answer: B Explanation: Writable streams are used to write data. Question 46. Which stream type can both read and write? A) Readable B) Writable
C) Duplex D) Object Answer: C Explanation: Duplex streams support both reading and writing. Question 47. Which method is used to pipe a readable stream to a writable stream? A) pipe() B) connect() C) stream() D) join() Answer: A Explanation: The pipe() method is used for connecting streams. Question 48. Which event signals that no more data will be provided on a readable stream? A) 'end' B) 'finish' C) 'close' D) 'done' Answer: A Explanation: The 'end' event indicates the readable stream is finished. Question 49. What is the main advantage of streams for processing large files? A) All data is loaded at once B) Data is processed in chunks, reducing memory usage C) Files are compressed automatically D) They are faster for small data Answer: B Explanation: Streams process data in chunks, making them memory efficient.
C) Reads, transforms, and writes data D) Closes data Answer: C Explanation: Transform streams can read and write, transforming data between. Question 54. Which method ends a writable stream? A) end() B) finish() C) close() D) done() Answer: A Explanation: end() finishes writing and closes the stream. Question 55. How do you listen for data events on a readable stream? A) readable.on('data', callback) B) readable.emit('data', callback) C) readable.write('data', callback) D) readable.pipe('data', callback) Answer: A Explanation: The 'data' event is emitted for chunks of data. Question 56. In package.json, which field specifies the package version? A) "ver" B) "version" C) "release" D) "pkgVersion" Answer: B Explanation: "version" specifies the package version.
Question 57. What command initializes a new package.json interactively? A) npm start B) npm init C) npm install D) npm create Answer: B Explanation: npm init creates package.json interactively. Question 58. Which of the following is NOT a valid script in package.json? A) "start" B) "test" C) "build" D) "main" Answer: D Explanation: "main" is not a script; it's for specifying entry point. Question 59. What is required to successfully run npm scripts? A) Node.js must be installed B) package.json must have a "scripts" field C) Both A and B D) Only package.json Answer: C Explanation: Both Node.js and scripts in package.json are required. Question 60. Which command runs the "test" script in package.json? A) npm run test B) npm test
Question 64. Which method reads a file as a stream in Node.js? A) fs.createReadStream() B) fs.readFile() C) fs.read() D) fs.openStream() Answer: A Explanation: fs.createReadStream() creates a readable stream. Question 65. What is the default encoding for fs.createReadStream? A) utf B) none (Buffer) C) ascii D) base Answer: B Explanation: No encoding by default; data is Buffer. Question 66. Which event is fired when a writable stream finishes writing all data? A) 'finish' B) 'end' C) 'close' D) 'done' Answer: A Explanation: 'finish' means all data is written. Question 67. Which command installs a package globally? A) npm install - g
C) npm install --save