The else if statement is used in JavaScript for ________.

  • conditional execution
  • error handling
  • multiple comparisons
  • branching based on multiple conditions
The else if statement in JavaScript is used for branching based on multiple conditions. It allows you to check additional conditions if the previous if condition is false.

You are tasked with creating tests for a complex system with multiple interacting components. How would you decide which components to mock or stub to achieve a balance between test isolation and reliability?

  • Mock all components to ensure complete isolation
  • Stub only the most complex components
  • Mock components that are external or slow
  • Stub components that are stable and well-tested
When testing a complex system, it's essential to strike a balance between test isolation and reliability. Mocking all components can lead to over-fragmented tests and make maintenance difficult. Stubbing only the most complex components may not ensure adequate coverage. To achieve this balance, you should mock components that are external or slow, as these can introduce variability and slow down tests. Stubbing components that are stable and well-tested can help reduce unnecessary complexity and speed up test execution.

What does the process object in Node.js primarily provide information about?

  • Operating system processes
  • Web browser processes
  • File I/O processes
  • Database processes
The process object in Node.js primarily provides information about operating system processes. It allows you to interact with and control the Node.js process, such as accessing command line arguments, environment variables, and exiting the process. It is not related to web browser, file I/O, or database processes.

When designing systems with Non-Blocking I/O, careful consideration must be given to avoid ________, where multiple asynchronous operations are competing for resources.

  • Callback Hell
  • Deadlock
  • Blocking I/O
  • Synchronous Execution
When designing systems with Non-Blocking I/O, careful consideration must be given to avoid "Callback Hell," also known as "Callback Pyramid" or "Callback Spaghetti." This occurs when multiple asynchronous operations are nested deeply, making code difficult to read and maintain.

How can you implement template inheritance in Pug?

  • extend layout.pug
  • include layout.pug
  • inherit layout.pug
  • template layout.pug
In Pug, template inheritance is implemented using the extend keyword followed by the name of the layout file. This allows child templates to inherit the structure and content of the specified layout file. The other options (include, inherit, and template) are not used for template inheritance in Pug.

How can you optimize the performance of a SQL query that reads a large amount of data?

  • Use indexes on columns frequently queried.
  • Avoid joins and subqueries.
  • Increase the page size of the database.
  • Fetch all data at once to minimize network latency.
To optimize the performance of a SQL query reading large data, you should use indexes on columns frequently queried. Indexes improve data retrieval speed. The other options may not necessarily lead to performance improvements and can even degrade performance.

You are tasked with evolving the schema of a critical, high-traffic database while minimizing downtime and data inconsistency. What strategies would you employ to safely apply schema migrations?

  • Use database migration tools with rollback support.
  • Apply schema changes during off-peak hours.
  • Utilize database versioning and backward-compatible changes.
  • Pause the database for maintenance during schema updates.
Option (1) is a common approach as it allows you to apply changes with rollback capabilities. Option (2) is valid to minimize the impact on users. Option (3) is also important, using versioning and backward-compatible changes ensures a smoother transition. Option (4) is typically not recommended, as it causes downtime.

Can you modify the package.json file after it has been created by the npm init command?

  • Yes, but only with admin privileges
  • No, it's read-only
  • Yes, it can be edited anytime
  • Yes, but only during project initialization
Yes, you can modify the package.json file after it has been created by the npm init command. It's a JSON configuration file that stores information about your project, and you can update it to add dependencies, scripts, and other project-related settings. It's a fundamental part of managing Node.js projects.

In Node.js, the process.cwd() method returns the ________.

  • current working directory
  • home directory
  • root directory
  • parent directory
In Node.js, the process.cwd() method returns the current working directory of the Node.js process. This directory is the base directory from which the Node.js process was started.

You are building a real-time data processing system where tasks are dependent on the completion of previous tasks. How would you structure your Promises/async functions to ensure the sequence is maintained?

  • Using async/await
  • Using Promise.then()
  • Using Promise.race()
  • Using setTimeout()
To ensure the sequence of tasks is maintained in a real-time data processing system, you should structure your code using async/await. This allows you to write asynchronous code in a more synchronous style, ensuring that each task awaits the completion of the previous one. The other options are not typically used for sequential task execution.