






























































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
A set of questions and answers related to the openjs node.js application developer (atlas) exam. It covers various topics including javascript fundamentals, asynchronous programming with promises, node.js global objects, file system operations, streams, and event handling. Each question is followed by the correct answer and a brief explanation, making it a useful resource for exam preparation and understanding key concepts in node.js development. The questions are designed to test knowledge of javascript and node.js, providing a comprehensive review of essential topics for application developers. This resource is ideal for those preparing for the openjs node.js application developer certification or seeking to enhance their understanding of node.js concepts.
Typology: Exams
1 / 70
This page cannot be seen from the preview
Don't miss anything!































































Question 1. Which keyword is used to declare a block-scoped variable in JavaScript? A) var B) let C) static D) final Answer: B Explanation: The let keyword is used to declare variables that are block-scoped, which means they are only accessible within the block in which they are defined. Question 2. What is the type of the result of: typeof null? A) "object" B) "null" C) "undefined" D) "boolean" Answer: A Explanation: In JavaScript, typeof null returns "object" due to a historical bug in the language. Question 3. Which statement about const variables in JavaScript is correct? A) Their value can never change B) They are function-scoped C) They must be initialized at declaration D) They can be redeclared Answer: C Explanation: const variables must be initialized at the time of declaration; otherwise, a syntax error is thrown. Question 4. What will be logged by console.log(1 + "1")? A) 2 B) 11
C) NaN D) undefined Answer: B Explanation: The number 1 is coerced to a string, so "1" + "1" results in string concatenation, yielding "11". Question 5. Which of these is NOT a valid primitive type in JavaScript? A) string B) boolean C) object D) symbol Answer: C Explanation: Object is not a primitive type; it is a reference type. The other options are primitive types. Question 6. What does the following function return? function f() { return; } A) null B) undefined C) 0 D) Error Answer: B Explanation: If a function does not explicitly return a value, it returns undefined by default. Question 7. Which method can be used to copy all enumerable properties from one or more source objects to a target object? A) Object.assign() B) Object.copy() C) Object.merge() D) Object.clone() Answer: A
A) "number" B) "NaN" C) "undefined" D) "object" Answer: A Explanation: NaN stands for "Not a Number", but its type is still "number" in JavaScript. Question 12. What is the prototype chain used for in JavaScript? A) Managing asynchronous code B) Inheritance C) Variable scoping D) Module import Answer: B Explanation: The prototype chain is the mechanism by which JavaScript objects inherit properties and methods from other objects. Question 13. What is the output of [1, 2, 3].map(x => x * 2)? A) [2, 4, 6] B) [1, 2, 3, 2, 4, 6] C) [1, 4, 9] D) [1, 2, 3] Answer: A Explanation: The map() method creates a new array with the results of calling a provided function on every element. Question 14. What does the following code output: console.log(0 == '0')? A) true B) false C) TypeError
D) undefined Answer: A Explanation: == performs type coercion, so 0 is converted to '0', making the comparison true. Question 15. Which of the following is NOT a valid way to declare a function in JavaScript? A) function foo() {} B) let foo = function() {} C) let foo = () => {} D) function:foo() {} Answer: D Explanation: function:foo() {} is not valid JavaScript syntax. Question 16. What does the following code output: console.log([] == false)? A) true B) false C) TypeError D) undefined Answer: A Explanation: [] is coerced to an empty string, which is falsy, so [] == false is true. Question 17. Which operator can be used to check both value and type equality? A) == B) === C) = D) equals Answer: B Explanation: === checks both value and type equality (strict equality). Question 18. Which of the following is NOT a method of Array?
Explanation: An async function can use the await keyword to pause execution until a Promise is resolved. Question 22. Which of these statements about await is correct? A) It can be used at the top-level of any script B) It can only be used inside async functions C) It blocks the entire program D) It works with callbacks Answer: B Explanation: await can only be used inside async functions. Question 23. What is the primary benefit of using Promises over callbacks? A) Promises are faster B) Promises avoid callback hell and are easier to chain C) Callbacks cannot handle errors D) Promises are synchronous Answer: B Explanation: Promises allow for more readable code and easier chaining compared to nested callbacks. Question 24. How do you handle errors in a Promise chain? A) .then() B) .catch() C) .resolve() D) .finally() Answer: B Explanation: .catch() is used to handle rejected Promises and errors in a Promise chain. Question 25. Which Node.js global object provides access to command-line arguments? A) process
B) global C) console D) module Answer: A Explanation: process.argv contains the command-line arguments passed when launching the Node.js process. Question 26. What does the fs.readFileSync method do? A) Reads a file asynchronously B) Reads a file synchronously C) Writes to a file D) Deletes a file Answer: B Explanation: fs.readFileSync blocks the event loop and reads the file synchronously. Question 27. Which method is used to write data to a file asynchronously using the fs module? A) fs.writeFileSync B) fs.appendFileSync C) fs.writeFile D) fs.saveFile Answer: C Explanation: fs.writeFile writes data to a file asynchronously. Question 28. What is a Buffer in Node.js? A) A way to handle strings only B) A global object for JSON C) A temporary storage for binary data D) A type of EventEmitter Answer: C
A) To manage child processes B) To emit and consume events C) To manage HTTP requests D) To perform file I/O Answer: B Explanation: EventEmitter allows objects to emit events and other objects to listen for those events. Question 33. How do you create a custom event in Node.js? A) Using process.emit B) Using EventEmitter.emit C) Using global.emit D) Using event.create Answer: B Explanation: EventEmitter.emit is used to trigger (emit) custom events. Question 34. Which method adds a listener for a specific event? A) on B) once C) listen D) addEvent Answer: A Explanation: The on method registers a listener for a specific event. Question 35. What does the once method do in an EventEmitter? A) Adds a listener that only fires once B) Removes a listener C) Emits an event D) Listens for multiple events Answer: A
Explanation: once adds a listener that will be invoked at most once for a particular event. Question 36. Which module is used to create child processes in Node.js? A) child_process B) children C) process_child D) sub_process Answer: A Explanation: The child_process module allows you to spawn child processes in Node.js. Question 37. What does child_process.exec do? A) Runs a command in a shell and buffers the output B) Forks a new Node.js process C) Reads a file asynchronously D) Emits an event Answer: A Explanation: exec runs a shell command and buffers the output for use in a callback. Question 38. How do you access the current working directory in Node.js? A) process.cwd() B) fs.cwd() C) os.getCwd() D) global.cwd() Answer: A Explanation: process.cwd() returns the current working directory. Question 39. Which event is emitted when a process exits? A) exit B) end
Question 43. Which syntax is used to import an ES Module? A) require('module') B) import module from 'module' C) module.import('module') D) import 'module' Answer: B Explanation: import ... from ... is the syntax for importing ES Modules. Question 44. What is the default export in ES Modules? A) export default B) export main C) export module D) export defaultModule Answer: A Explanation: export default is used to specify the default export of a module. Question 45. What happens if you call process.exit()? A) The process pauses B) The process exits immediately C) The process restarts D) Nothing happens Answer: B Explanation: process.exit() ends the Node.js process immediately. Question 46. How can you read a directory asynchronously using fs? A) fs.readDir B) fs.readDirectory C) fs.readdir D) fs.dirRead
Answer: C Explanation: fs.readdir is used to asynchronously read the contents of a directory. Question 47. What is the primary function of the os module in Node.js? A) Handle file I/O B) Provide operating system-related utility methods C) Manage child processes D) Emit events Answer: B Explanation: The os module provides operating system-related utility methods and properties. Question 48. Which method in the fs module is used to create a new directory asynchronously? A) fs.mkdir B) fs.makeDir C) fs.createDir D) fs.dirMake Answer: A Explanation: fs.mkdir creates a new directory asynchronously. Question 49. What is the output of: console.log(typeof undefined)? A) "undefined" B) "object" C) "null" D) "string" Answer: A Explanation: The type of undefined is "undefined". Question 50. Which of the following statements about JavaScript objects is true? A) They cannot be dynamically extended
Explanation: Variable names cannot start with a number. Question 54. What is the result of typeof function(){}? A) "function" B) "object" C) "undefined" D) "string" Answer: A Explanation: typeof returns "function" for functions. Question 55. Which keyword is used to define a constant in JavaScript? A) const B) constant C) let D) var Answer: A Explanation: const is used to define a constant. Question 56. What is the output of: "5" === 5? A) true B) false C) undefined D) null Answer: B Explanation: === checks both value and type, so "5" and 5 are not strictly equal. Question 57. Which method removes the last element from an array and returns it? A) shift B) pop
C) unshift D) push Answer: B Explanation: pop removes the last element from an array. Question 58. What is the default value of a variable that is declared but not assigned? A) null B) undefined C) 0 D) false Answer: B Explanation: Declared but uninitialized variables have the value undefined. Question 59. Which array method creates a new array with all elements that pass the test implemented by the provided function? A) map B) forEach C) filter D) reduce Answer: C Explanation: filter creates a new array with elements that pass the test. Question 60. What does the following expression return: Boolean("")? A) true B) false C) null D) undefined Answer: B Explanation: An empty string is falsy, so Boolean("") returns false.
C) Returns the methods of an object D) Returns the length of an object Answer: B Explanation: Object.keys() returns an array of the object's own enumerable property names. Question 65. Which of the following is NOT a falsy value in JavaScript? A) 0 B) "" C) "false" D) null Answer: C Explanation: "false" is a non-empty string, which is truthy. Question 66. What is the output of: typeof []? A) "array" B) "object" C) "list" D) "undefined" Answer: B Explanation: Arrays are objects in JavaScript, so typeof [] returns "object". Question 67. What does the new keyword do in JavaScript? A) Defines a new variable B) Creates an instance of an object C) Declares a function D) Imports a module Answer: B Explanation: new is used to create an instance of a user-defined object type or one of the built-in object types.
Question 68. What is the main use of Promises in JavaScript? A) Handling synchronous operations B) Handling asynchronous operations C) Managing modules D) Defining classes Answer: B Explanation: Promises are used to handle asynchronous operations in JavaScript. Question 69. What does the .catch() method do in a Promise chain? A) Adds a function to run after the Promise is fulfilled B) Handles errors and rejected Promises C) Runs code no matter what D) Starts the chain Answer: B Explanation: .catch() is used to handle errors and rejected Promises. Question 70. What is the output of: [1,2,3].reduce((a,b) => a + b, 0)? A) 0 B) 3 C) 6 D) [1,2,3] Answer: C Explanation: reduce adds up all elements starting from 0, resulting in 6. Question 71. What does the .then() method return in Promises? A) Nothing B) A new Promise C) The same Promise