linkedin-skill-assessments-quizzes

Node.js

Q1. When a javaScript function is invoked (called) in Node, where is a new frame placed?

Explanation: From javascripttutorial: reference

Q2. Which of the following is a core module in Node?

Explanation: From flaviocopes docs: reference

Q3. Which of the following Buffer class methods returns an uninitialized buffer?

Explanation: From official docs: reference

Q4. Which of the following modules is NOT a built-in module in Node?

Explanation: From flaviocopes docs: reference

Q5. Which fs module method can be used to read the content of a file without buffering it in memory?

Explanation: From official docs: reference To minimize memory costs, when possible prefer streaming via fs.createReadStream().

Q6. Which of the following DNS module methods uses the underlying OS facilities and does not necessarily perform any network communication?

Explanation: From official docs: reference

Q7. How do you check that a value is a date object in Node?

Explanation: From official docs: reference

Q8. Can you create an https web server with Node.js?

Explanation: From official docs: reference

Q9. What is the Api that is designed to insulate Addons from changes in the underlying JavaScript engine?

Explanation: From official docs: reference

Q10. Which CLI option can you use to debug a node script in Chrome DevTools?

Explanation: From official docs: reference

Q11. What command would you use to count the number of logical CPUs on the machine that is running Node?

Explanation: From coderrocketfuel docs: reference

Q12. Which of the following is a method on the console object?

Explanation: From official docs: reference

Q13. Which object is used to manage the cache of required modules?

Explanation: From official docs: reference

Q14. What is the command to silence all process warnings?

Explanation: From official docs: reference

Q15. How can you use the promise API with a callback-based function such as child_process.exec?

Explanation: From official docs: reference

Q16. Which of the following is NOT a Node repl command?

Explanation: From official docs: reference

Q17. Which statement is true when you run the code shown below?

require('child_process').fork('script.js');

Explanation: From official docs: reference

Q18. If EventEmitter is in scope, which of the following lines of code will have an event emitter emitting a change event?

Explanation: Because the EventEmitter is already in scope. No need to create new one.

Q19. Which of the following objects is a stream

Explanation: process.stdout is Buffer type.

Q20. Which module variable holds the resolved absolute path of the current module file?

Q21. If the child_process module methods are in scope, what is a current way to execute the command ps -ef using a child process?

Reference: From official docs: reference

Q22. Which console method can be used to print the stack trace to the point of its execution?

Q23. When you run JavaScript in a Node.js application, which of the following elements in a Node.js stack actually executes that JavaScript?

Q24. Looking at the code below, what does the console show?

const http = require('http');
 const hostname = '127.0.0.1'; const port = 3000;
 const server = http.createServer((req, res) => {
  res.statusCode = 200;  res.setHeader("Content-Type", "text/plain");  res.end("Hello World\n");
});
server.listen(port, hostname, () => { console.log(`server running at http://${hostname}:${port}/`); });

Explanation: From official docs: reference

Q25. What is the purpose of the path module?

Explanation: From official docs: reference

Q26. How do you make an HTTP server object active and listen to requests on certain ports?

Q27. What does the code shown below do?

const fs = require('fs'); const os = require('os');
const system = os.platform(); const user = os.userInfo().username;
fs.appendFile('hello.txt', `Hello ${user} on ${system}`, (err) => { if (err) throw err; console.log('The data was appended to file!');}
);

Q28. How do you start a Node application, if the entry file is indexjs?

Q29. What is the purpose of the file system (fs) module?

Explanation: From official docs: reference

Q30. What is the Node LTS version?

Q31. Which of the following is NOT a valid stream in Node?

Q32. You have a script.js file with the single line of code shown here. What will be the output of executing script.js with the node command?

console.log(arguments);

Explanation:: Reference Article The output of executing console.log(arguments); in Node.js will be a ReferenceError: arguments is not defined. The arguments object is not available in Node.js, as it is a specific feature of the browser JavaScript environment. In browsers, the arguments object is an array-like object that contains all of the arguments that were passed to a function. However, in Node.js, there is no arguments object, and the only way to access the arguments that were passed to a function is to explicitly declare them in the function’s parameter list.

Q33. Which choice is not a valid method on event emitters?

Q34. Which special object is an instance of EventEmitter?

Reference

Q35. What is the command to get a list of available commands for Node.js?What is the command to get a list of available commands for Node.js?

Q36. When a request event is received in the HTTP module, what is the type of the first argument passed to that event, usually named req?

Q37. What are the arguments passed to the module wrapper function?

Q38. Which library provides Node.js with the event loop?

Q39. What does the .node file extension represent?

Q40. What can you export with module.exports?

Q41. Which core module in Node can you use to take advantage of multicore systems?

Q42. Which core Node module has wrappers for OpenSSL methods?

Q43. Which line imports a promise-based version of the readFile method?

Q44. According to the rules of semantic versioning, what does a release incrementing the third number in an npm version string communicate to users about the release changes?

Q45. What does REPL stand for?

Q46. Which file does node-gyp use to read the build configuration of a module?

Q47. Which core module in Node can you use for testing?

Q48. Which core module in Node provides an API to register callbacks to track asynchronous resources created inside a Node.js application?

Explanation: From official docs: reference

Q49. Which Node.js module should you use when you need to decode raw data into strings?

Refrence

Q50. Which global object acts like a bridge between a Node script and the host operating system?

Explanation: _process is an global object and act like a bridge, the others aren’t

  1. source
  2. source

Q51. Which statement is true about Node.js and threads?

Explanation: https://www.geeksforgeeks.org/why-node-js-is-a-single-threaded-language/

Q52. Which statement about event emitters is false?

Q53. Which core module in Node can you use to compile and run JavaScript code in a sandbox environment?

Q54. How would you determine the number of cluster instances to start when using the cluster module?

Explanation: From official docs: https://nodejs.org/api/cluster.html#cluster_cluster

Q55. You have to read a large text file, replace some words in it, and write it back to a new file. You know that the memory on your target system is limited. What should you do?

Explanation: From official docs: https://nodejs.org/api/readline.html#readline_example_read_file_stream_line_by_line

Q56. Which choice is not a Node global object?

Explanation: exports may appear to be global but is not. Refrence

Q57. What is the correct way to pipe a readable stream and a writable stream?

Q58. How can you convert path segments into a string using the platform-specific separator as a delimiter?

Explanation: From official docs: reference

Q59. What is the purpose of N-API?

Q60. What is a process object and its role?

Q61. What will this code log to the console?

// File: person.js
exports.name = "Jane";

// File: index.js
const person = require('./person.js');
console.log(person);

Q62. What will this code log to the console?

// File: person.js
exports = "John";

// File: index.js
const person = require('./person.js');
console.log(person);

Q63. Is it possible to write tests in Node.js without an external library?

From the article: Making a Testing Framework in Node.js (Without any External Libraries)

Q64. Which assert module method is usually used to test the error-first argument in callbacks?

Q65. Which choice is not a method on the util module?

Q66. Which choice is not a subclass of the Error class?

Q67. What is Node built on?

Refrence

Q68. How does it affect the performance of a web application when an execution path contains a CPU-heavy operation, such as calculating a long Fibonacci sequence?

Q69. What is used for parsing and running Javascript in Node.js?

Refrence

Q70. What is the importance of having good practices around status code in your response?

Q71. How can ECMAScript modules be used natively in Node?

Reference

Q72. When exploring the Node documentation’s features, what are the stability ratings?

Q73. Which DNS module method uses the underlying OS facilities and does not necessarily perform any network communication?

Q74. When you require(something), where will Node.js attempt to resolve(something)?

Q75. An external library has its own codebase and license. It is not managed by the Node.js core team. Which choice is an external library that Node.js uses?

Reference

Q76. What is the main purpose of the package-lock.json file?

Q77. What response will you get when you send a get requests to the server with this code?

const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Refrence

Q78. What is the primary function of the npm command in Node.js development?

Explanation: The npm command is the Node Package Manager and is primarily used to manage packages and dependencies for Node.js projects. It allows developers to install, update, and manage packages from the npm registry.

Q79. In Node.js, how can you handle asynchronous operations effectively to avoid callback hell?

Explanation: To handle asynchronous operations effectively and avoid callback hell, it’s recommended to use Promises, async/await, or libraries like async.js. These techniques provide a more structured and readable way to work with asynchronous code.

Q80. Which core module in Node.js can be used to create web servers?

Explanation: The http core module in Node.js can be used to create web servers. It provides the necessary functionality to handle HTTP requests and responses, making it possible to create web applications and APIs.

Q81. What is the purpose of the os module in Node.js?

Explanation: The os module in Node.js is used to provide information about the host operating system. It offers functions to access details about the CPU, memory, and network interfaces, making it useful for system-related tasks.

Q82. How can you serve static files, such as HTML, CSS, and images, in a Node.js web application?

Explanation: To serve static files in a Node.js web application, you can use middleware like express.static in combination with the Express.js framework. This middleware simplifies the process of serving HTML, CSS, images, and other static assets.

Q84. How can you terminate a Node.js application programmatically?

Explanation : To terminate a Node.js application, you can either send a SIGINT signal or call process.exit() programmatically.

Q85. What is the purpose of the child_process module in Node.js?

Explanation : The child_process module is used for creating and managing child processes to run external commands or scripts independently.

Q86. What is the primary purpose of the cluster module in Node.js?

Explanation : The primary purpose of the cluster module in Node.js is to utilize multicore systems efficiently by forking multiple Node.js processes to distribute workloads.

Q87. Which method of the fs module in Node.js is used to check if a file exists asynchronously?

Explanation: The fs.access method in Node.js is used to check if a file exists asynchronously. It is a recommended way to check for the existence of a file as it does not throw an error if the file doesn’t exist, and it’s more efficient than using fs.exists or fs.stat. If the file exists, the callback function will be called with no error. If the file doesn’t exist, the callback will be called with an error.

Q88. Which core module in Node.js is used for network programming and creating network applications?

Explanation: The net core module in Node.js is used for network programming and creating network applications. It provides the necessary functionality for creating both TCP and Unix socket servers and clients.

Q89. What is the purpose of the util.promisify method in Node.js?

Explanation: The util.promisify method in Node.js is used to convert a callback-style function into a function that returns a Promise. It simplifies working with asynchronous functions by allowing you to use async/await syntax and Promise-based error handling.

Q90. Which Node.js module provides an interface for interacting with the file system, including reading and writing files?

Explanation: The fs module in Node.js provides an interface for interacting with the file system. It allows you to perform various file-related operations, including reading and writing files, creating directories, and more.