Question 150
A broad modernization mixes dependency upgrades, formatting, and behavior changes. What improves reviewability?
- Remove commit descriptions.
- Combine all future changes into the same patch.
- Review only the final file count.
- Separate coherent changes into independently understandable patches.
Explanation
Correct Answer
D:Focused changes make causes and regressions easier to identify without requiring reviewers to untangle unrelated modifications.
Incorrect Answers
A:Descriptions help reviewers understand intent and do not cause the underlying scope problem.
B:Additional unrelated scope makes validation and rollback harder.
C:File count does not explain the semantics or risk of the modifications.
Question 151
A unit test checks how an agent wrapper handles a tool timeout. What test dependency is appropriate?
- A mock that always returns success.
- No tool invocation in the test.
- A production service that may or may not fail.
- A controlled test double that raises the expected timeout.
Explanation
Correct Answer
D:A deterministic simulated failure exercises the wrapper’s recovery path without relying on an unpredictable external outage.
Incorrect Answers
A:Success never exercises the timeout-handling branch being tested.
B:Skipping the interaction leaves the intended recovery path untested.
C:Uncontrolled behavior makes the test unreliable and potentially costly.
Question 152
Unit tests mock the provider perfectly, but deployment fails on the real request shape. What additional check is needed?
- More tests using the same inaccurate mock.
- A controlled integration test against the supported provider contract.
- Only another mock that repeats the existing assumed provider schema.
- Removing validation from the mock.
Explanation
Correct Answer
B:Mocks can reproduce incorrect assumptions. Boundary testing verifies that actual serialization and responses match the external interface.
Incorrect Answers
A:Repeatedly testing the same assumption does not verify its compatibility with the real service.
C:A second mock can reproduce the same mistaken assumption; the missing check must exercise the real integration contract.
D:A less restrictive mock can conceal even more integration errors.
Question 153
Python code registers handlers inside a loop as handlers[name] = lambda: invoke(name). Later, every handler invokes the loop's final name. What should change?
- Sort the registry keys after the loop finishes.
- Bind each iteration's name when creating its handler.
- Copy the handler dictionary after the registration loop finishes.
- Rename the loop variable while keeping the same lambda capture pattern.
Explanation
Correct Answer
B:The closure looks up the captured variable when called, after the loop has changed it. A factory or default argument can capture the intended value for each registered callable.
Incorrect Answers
A:Sorting changes presentation order, not the variable referenced by each closure. Every handler would still resolve the same final name.
C:Copying the mapping retains the same function objects and captured variable behavior. It does not bind different name values into those functions.
D:Changing the variable's spelling does not change late binding. Each callable must retain the value associated with its creation iteration.
Question 154
An environment variable contains "30" for a numeric timeout. What should configuration loading do?
- Ignore malformed values without recording the effective setting.
- Parse and validate its type and permitted range at startup.
- Pass it unchanged into arbitrary arithmetic.
- Assume every environment value is already numeric.
Explanation
Correct Answer
B:Environment values are strings; explicit conversion prevents delayed type errors and catches invalid limits before serving requests.
Incorrect Answers
A:Silent fallback makes the deployed behavior difficult to understand and audit.
C:Implicit assumptions can cause errors or unintended string operations.
D:String storage does not supply the application’s required runtime type.
Question 155
Two requests read version 7 of a record and propose different updates. What prevents a silent lost update?
- Use version-aware conditional updates and resolve conflicts.
- Let the latest network response win without checking.
- Protect updates only with a lock local to one of several application processes.
- Put both updates in the model prompt after writing.
Explanation
Correct Answer
A:The write succeeds only if its expected version remains current, exposing concurrent changes instead of overwriting them blindly.
Incorrect Answers
B:Arrival order can discard valid changes and does not reconcile conflicting intentions.
C:A process-local lock does not coordinate other workers, so both requests can still write based on the same stale version.
D:Post-write discussion cannot prevent the already lost update.
Question 156
A Python helper is defined as def new_history(messages=[]): messages.append('start'); return messages. Successive calls with no argument return an increasingly long list. Why?
- The function body runs once at definition time and its result is cached.
- Python automatically copies every default list before a call.
- The mutable default is created once and reused across calls.
- Appending creates a new default list, which replaces all earlier results.
Explanation
Correct Answer
C:Default argument evaluation occurs when the function is defined. Use a sentinel such as None and allocate a new list inside the function when callers should receive independent histories.
Incorrect Answers
A:The body runs on each call, as shown by the growing list. It is the default list object that is created once and reused.
B:That would isolate the lists and prevent the observed accumulation. A mutable default object is not implicitly cloned for each invocation.
D:append mutates the existing list rather than creating a replacement. The shared object explains why successive no-argument calls accumulate entries.
Question 157
A merge conflict affects a tool schema and its handler. How should it be resolved?
- Reconcile both contracts and validate the merged behavior.
- Accept the schema from one branch and the handler from the other without compatibility checks.
- Delete conflict markers and keep both function bodies unchanged.
- Resolve only the documentation file.
Explanation
Correct Answer
A:Accepting lines mechanically can leave the schema and implementation inconsistent; semantic compatibility must guide resolution.
Incorrect Answers
B:Each side may be correct in isolation while their combination uses incompatible fields or parameter semantics.
C:Removing markers alone can leave duplicate or contradictory implementations.
D:The executable contract remains conflicted even if documentation reads cleanly.
Question 158
A generated function passes linting but returns the wrong classification. What does this demonstrate?
- Static style checks do not establish required behavioral correctness.
- The test must be wrong because syntax is valid.
- Linting guarantees every business rule.
- Increase lint strictness and skip behavior tests until lint is clean.
Explanation
Correct Answer
A:Lint checks selected static properties. Behavioral tests are needed to show whether the function applies the required classification rule to relevant inputs.
Incorrect Answers
B:Syntactically valid code can implement an incorrect decision.
C:Style and selected static checks cannot prove all domain behavior.
D:Stricter lint may find additional static issues, but it need not recognize the incorrect domain classification. Behavioral assertions are still required.
Question 159
A summarizer must never output an account identifier absent from its authorized input set. What test style directly expresses this?
- Check the identifier-subset invariant across varied inputs.
- Compare only punctuation with one saved response.
- Accept any response containing an identifier.
- Test only the empty-input case.
Explanation
Correct Answer
A:An invariant describes a required relationship rather than one exact wording, making violations detectable across many cases.
Incorrect Answers
B:Punctuation does not establish whether identifiers came from authorized inputs.
C:Presence alone ignores whether the identifier is permitted.
D:One narrow case does not exercise the relationship across normal varied inputs.
Question 160
A synchronous endpoint has a three-second deadline. Its retry policy can wait ten seconds. What must be reconciled?
- Only the timeout of the last attempt.
- Only the average response time of successful requests.
- The total retry and timeout budget with the endpoint deadline.
- Only the maximum number of attempts, ignoring backoff duration.
Explanation
Correct Answer
C:Per-attempt settings must fit the overall request contract; otherwise recovery guarantees an unacceptable response delay.
Incorrect Answers
A:The endpoint deadline includes earlier attempts and backoff, so a final-attempt limit does not bound the entire retry sequence.
B:An average success metric does not enforce the maximum time a failing request can spend in retries.
D:Attempt count alone does not bound total elapsed time when each attempt and delay consumes the endpoint deadline.