When securing a web application using JWT, implementing ________ helps in mitigating the risk of token interception.

  • Token expiration
  • Strong encryption
  • Public key authentication
  • Rate limiting
When securing a web application with JWT (JSON Web Tokens), implementing strong encryption is crucial to mitigate the risk of token interception. Encryption ensures that the token's content remains confidential even if intercepted. Token expiration (Option 1) deals with token validity periods, while public key authentication (Option 3) is related to how JWT signatures are verified. Rate limiting (Option 4) is a measure to control access but doesn't directly address token interception.

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.

You are tasked with developing a file upload module in Node.js. The files uploaded by users are binary data. How would you handle the incoming binary data to ensure data integrity and optimal resource utilization?

  • Use streams to handle and process binary data in chunks
  • Read the entire binary data into memory before processing
  • Convert binary data to hexadecimal for storage
  • Store binary data in a JSON format
To ensure data integrity and optimal resource utilization when handling binary data in a file upload module, it's best to use streams to handle and process binary data in chunks. This approach minimizes memory usage and ensures data integrity. Reading the entire binary data into memory is not efficient, and the other options are not suitable for storing binary data.

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.