How does hoisting work in JavaScript?
- Assignments are moved to the top of the scope during compilation
- Declarations are moved to the top of the scope during compilation
- Functions are moved to the top of the scope during compilation
- Variables are moved to the top of the scope during runtime
Hoisting in JavaScript refers to the behavior where function declarations are moved to the top of the scope during compilation, allowing them to be used before they are declared.
In a Node.js application, JavaScript is primarily used for _______ scripting.
- Client-side
- Database
- Front-end
- Server-side
In a Node.js application, JavaScript is primarily used for server-side scripting. This is a distinctive feature of Node.js, enabling server-side development using JavaScript.
What are the key components of a comprehensive logging strategy in a microservices architecture?
- Centralized log storage, structured log formats, correlation IDs, and log aggregation
- Client-side logging, lightweight log formats, and real-time alerts
- Only server-side logging, comprehensive alerting, and distributed log storage
- Unstructured logs, decentralized storage, and real-time log analysis
A comprehensive logging strategy in microservices includes centralizing logs, using structured formats for easy analysis, implementing correlation IDs for request tracking, and aggregating logs to simplify troubleshooting and analysis.
What is the time complexity of accessing an element in an array?
- O(1)
- O(log n)
- O(n)
- O(n^2)
The time complexity of accessing an element in an array is O(1) or constant time. This is because arrays provide direct access to any element using its index, and the access time remains constant regardless of the array size.
In Cassandra, a _______ determines the placement of data on nodes in the cluster.
- Consistency Level
- Partition Key
- Replication Factor
- Super Column
In Cassandra, the placement of data on nodes is determined by the Partition Key. It is crucial for distributing data across the cluster efficiently.
Which SQL clause is used to filter results based on a specified condition?
- FROM
- GROUP BY
- SELECT
- WHERE
The WHERE clause in SQL is used to filter results based on a specified condition. It allows you to specify conditions that the data must meet to be included in the result set.
Which type of attack involves an attacker stealing a user's session token and using it to impersonate the user?
- Cross-Site Request Forgery (CSRF)
- Cross-Site Scripting (XSS)
- SQL Injection
- Session Hijacking
Session Hijacking involves an attacker stealing a user's session token and using it to impersonate the user. This attack allows unauthorized access to sensitive data.
_______ profiling helps identify areas of code that consume excessive resources or cause bottlenecks.
- Code
- Memory
- Performance
- Time
Performance profiling involves analyzing a program's runtime behavior to identify bottlenecks and resource-heavy sections. It helps optimize code for better efficiency and speed.
In which situations is the Factory Method design pattern useful?
- Creating objects with multiple possible representations
- Decoupling the concrete classes from the client
- When a class cannot anticipate the class of objects it must create
- When the system needs to be independent of how its objects are created, composed, and represented
The Factory Method design pattern is useful when you want to decouple the client code from the concrete classes it uses, allowing flexibility in object creation without changing the client code.
How can you center align an element horizontally using CSS?
- align: center;
- horizontal-align: center;
- margin: auto;
- text-align: center;
To center align an element horizontally in CSS, you can use margin: auto;. This property automatically distributes the remaining space on both sides of the element, centering it within its container.