In a real-time chat application, you need to implement a feature that notifies users when someone is typing a message. How would you accomplish this using JavaScript?
- Use AJAX polling to check typing status
- Use WebSocket to send typing status
- Use oninput event listener
- Use setTimeout and clearTimeout for delay
Using WebSocket allows real-time communication between clients and the server, making it ideal for notifying users when someone is typing. setTimeout and clearTimeout are more suitable for handling delays and timeouts, not real-time updates. AJAX polling introduces unnecessary overhead and delays. The oninput event listener is used for detecting input changes, not real-time status updates.
___________ is a divide and conquer sorting algorithm.
- Bubble Sort
- Insertion Sort
- Merge Sort
- Selection Sort
Merge sort is a classic example of a divide and conquer algorithm, where the sorting process involves dividing the array into smaller subarrays, sorting them individually, and then merging them back together in sorted order.
Which Agile methodology emphasizes adaptability and customer collaboration over strict planning?
- PRINCE2
- Scrum
- Six Sigma
- Waterfall
Scrum is an Agile methodology that emphasizes adaptability and customer collaboration over strict planning. It encourages iterative development, frequent feedback, and a focus on delivering value to customers. Scrum teams are self-organizing and cross-functional, with a Scrum Master facilitating the process rather than dictating tasks. This approach promotes flexibility, continuous improvement, and customer satisfaction by responding to changing requirements throughout the development cycle.
How does Node.js handle clustering for scaling applications?
- Implements microservices architecture
- Utilizes Docker containers
- Utilizes load balancing
- Utilizes the cluster module
Node.js clustering allows applications to utilize multiple CPU cores efficiently by creating child processes (workers) using the cluster module. Each child process runs on a separate core, enabling parallel processing and improved performance. This approach is particularly effective for scaling applications across multiple cores without relying solely on the single-threaded nature of Node.js.
The _______ pattern is often used in RESTful APIs to provide access to related resources.
- Composite
- Composite Entity
- Facade
- Repository
The Repository pattern is commonly used in RESTful APIs to abstract the data access layer and provide a simplified interface for accessing related resources. It helps in organizing code and separating concerns by providing a centralized mechanism for handling database operations related to specific resources.
You're tasked with redesigning a legacy database system that suffers from numerous anomalies. Explain how you would approach the normalization process to address these issues and improve overall database performance.
- Break down the database into fewer tables to simplify it
- Combine multiple tables into one for faster access
- Identify and eliminate redundant data by dividing tables and using foreign keys
- Use non-normalized data to improve performance
In a legacy system, normalization involves identifying redundant data and dividing tables to eliminate anomalies such as update, insertion, and deletion anomalies. This is achieved by breaking down data into fewer tables, using foreign keys to establish relationships, and ensuring data integrity. Combining tables or using non-normalized data would not address the underlying issues of redundancy and anomalies.
What is the significance of a block size in a file system?
- Affects the maximum file size
- Determines the number of files that can be stored
- Determines the type of file system
- Influences the speed of file access
The block size in a file system plays a crucial role in determining the speed of file access. A smaller block size can lead to more efficient storage utilization for small files but may result in increased overhead for large files due to more blocks being allocated. On the other hand, a larger block size can improve the performance of accessing large files but may lead to wasted space for small files. Therefore, the block size choice depends on the expected file sizes and access patterns in a given system, balancing efficiency and performance accordingly.
Which ACID property ensures that transactions are isolated from each other to prevent interference?
- Atomicity
- Consistency
- Durability
- Isolation
The ACID property that ensures transactions are isolated from each other to prevent interference is Isolation. Isolation ensures that concurrent transactions do not see each other's intermediate states, thus preventing interference and maintaining data integrity.
The durability aspect of ACID properties often involves techniques such as ___________ to ensure data persistence.
- Redundancy
- Replication
- Recursion
- Regression
The correct option is "Replication." Durability in ACID properties refers to the guarantee that once a transaction is committed, its changes will persist even in the event of system failures or crashes. Replication techniques, such as maintaining multiple copies of data across different storage locations or using backup servers, are employed to ensure data durability. These strategies help in recovering data and maintaining system availability despite hardware or software failures.
What does REST stand for in RESTful APIs?
- Reliable State Transfer
- Remote State Transfer
- Representational State Transfer
- Resource State Transfer
Representational State Transfer (REST) is an architectural style for distributed hypermedia systems. It emphasizes scalability, reliability, and the uniform interface between components. RESTful APIs use HTTP methods like GET, POST, PUT, DELETE to manipulate resources.