TDD promotes writing _______ that fail before writing new code to pass them.
- Comments
- Documentation
- Requirements
- Tests
Test-Driven Development (TDD) promotes writing tests that fail before writing new code to pass them. This iterative approach ensures that each new piece of code is validated against predefined test cases, contributing to a more robust and reliable codebase.
Explain a real-world scenario where the use of ACID properties in a database transaction is critical to ensuring data integrity.
- Blog Comments
- Logging Inventory Changes
- Online Banking Transactions
- User Authentication
In online banking transactions, the use of ACID properties (Atomicity, Consistency, Isolation, Durability) is critical to ensure the integrity of financial data. A failed transaction could lead to inconsistencies in the user's account balance, emphasizing the need for transactional reliability.
The indexOf() method in JavaScript returns the position of the first occurrence of a specified _______ within a string.
- Character
- Element
- Substring
- Value
The indexOf() method returns the position of the first occurrence of a specified character within a string. It helps in finding the index of a particular character or substring.
What is the purpose of "git cherry-pick"?
- Applying a specific commit to another branch
- Creating a new branch from the latest commit
- Merging two branches with conflicting changes
- Reverting all changes in the working directory
The purpose of "git cherry-pick" is to apply a specific commit from one branch to another. It allows developers to select and incorporate individual commits into a different branch, facilitating the selective integration of changes.
In monitoring systems, _______ metrics provide insights into the health and performance of individual system components.
- Component-level
- Infrastructure
- Performance
- System-wide
In monitoring systems, component-level metrics provide insights into the health and performance of individual system components. These metrics help identify bottlenecks or issues at the granular level, aiding in efficient troubleshooting and optimization.
You accidentally delete a file in your Git repository. What command would you use to restore the file from a previous commit?
- git checkout
-- file-path - git reset --hard HEAD~1
- git restore --source=
--staged --worktree file-path - git revert
The correct command is git restore --source= --staged --worktree file-path where you restore the file from a specific commit using the restore command.
You are designing a banking application where multiple users can transfer money between accounts concurrently. How would you ensure data consistency and avoid concurrency issues?
- Caching without Locking
- Optimistic Concurrency Control
- Pessimistic Concurrency Control
- Using Database Transactions
In a banking application, ensuring data consistency during concurrent transactions is critical. Using database transactions provides a reliable method to maintain atomicity, consistency, isolation, and durability (ACID properties). This approach helps prevent issues such as lost updates or inconsistent states.
Explain the concept of cache coherency in distributed caching systems.
- Ensures that all nodes in the system have consistent data
- Maximizes cache size in a single node
- Minimizes the use of caching in distributed systems
- Prioritizes caching in specific nodes
Cache coherency in distributed systems ensures that all nodes have consistent data by synchronizing their caches. It prevents data inconsistencies across the network.
How does Git mark merge conflicts in the affected files?
- Adding a "Conflict" label to conflicted lines
- Appending "-conflict" to file names
- Creating a separate conflicted branch
- Using special conflict markers (<<<<<<<, =======, >>>>>>>)
Git marks merge conflicts in the affected files using special conflict markers like <<<<<<<, =======, and >>>>>>>. These markers indicate the conflicting sections that need manual resolution.
When resolving conflicts in Git, the modified files must be _______ before committing.
- Committed
- Merged
- Reverted
- Staged
When resolving conflicts in Git, the modified files must be staged (using "git add") after resolving the conflict but before committing the changes. Staging indicates that the conflicts have been addressed and are ready to be included in the next commit.