First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1Software Development and Design
A team is designing a new application and wants to apply the principle of separation of concerns. Which design choice best reflects that principle?
- Defer all modular decomposition until performance profiling shows which parts are slow
- Duplicate business rules in each layer so that layers stay independent of one another
- Isolate data access, business logic, and user interface into distinct modules with defined interfaces Correct answer.
- Combine persistence, business rules, and presentation in a single module to reduce file count
Explanation
Separation of concerns assigns each distinct responsibility to its own module so that changes in one area do not ripple through unrelated code. Keeping data access, business logic, and presentation behind explicit interfaces lets each evolve and be tested independently.
Question 2Software Development and Design
Which statement accurately describes the relationship between a design pattern and a software framework?
- A pattern is a reusable solution description, while a framework is concrete reusable code that calls application code Correct answer.
- A pattern and a framework are synonyms, since both describe abstract collaborations among classes
- A pattern is compiled library code, while a framework is only a documented convention with no executable components
- A framework must be implemented from scratch for each project, while a pattern ships as a binary dependency
Explanation
Design patterns are named, reusable descriptions of how to solve recurring design problems; they are not executable code. A framework is concrete, reusable code that typically inverts control and invokes application-supplied code.
Question 3Software Development and Design
An application must support multiple interchangeable algorithms for calculating shipping cost at runtime. Which pattern most directly fits this requirement?
- Facade
- Singleton
- Strategy Correct answer.
- Observer
Explanation
The Strategy pattern encapsulates a family of interchangeable algorithms behind a common interface so the algorithm can be selected at runtime. This matches swapping shipping-cost calculations without modifying the client.
Question 4Software Development and Design
A developer wants to write an automated unit test for a function that computes a discount. Which characteristic is most important for that test?
- It asserts several unrelated outcomes in a single test method
- It verifies one behavior with a deterministic assertion and no external dependencies Correct answer.
- It requires a live production database to validate realistic data
- It runs only after the full integration suite completes successfully
Explanation
A good unit test is focused on a single behavior, deterministic, and isolated from external systems such as databases or networks. That isolation makes failures easy to localize and keeps the suite fast and reliable.
Question 5Software Development and Design
Which HTTP status code should an API return when a request is syntactically valid but fails authentication because credentials are missing or invalid?
- 400 Bad Request
- 403 Forbidden
- 404 Not Found
- 401 Unauthorized Correct answer.
Explanation
401 Unauthorized signals that the request lacks valid authentication credentials for the target resource. It is distinct from 403, which indicates the client is authenticated but not permitted.
Question 6Software Development and Design
In a Git-based workflow, what is the primary purpose of a feature branch?
- To replace tags as the mechanism for marking production releases
- To prevent developers from fetching updates from the remote repository
- To permanently store release binaries separate from source code
- To isolate work in progress so the main branch stays stable until changes are reviewed and merged Correct answer.
Explanation
Feature branches isolate development work so that incomplete or experimental changes do not destabilize the shared mainline. Changes reach the main branch only after review and merge, supporting collaboration and continuous integration.
Question 7Software Development and Design
Which statement best describes the role of an API contract in a microservices architecture?
- It specifies the internal implementation classes each service must use
- It guarantees that all services share a single database schema and deployment schedule
- It removes the need for versioning because consumers never change
- It defines the agreed request and response structure so independently deployed services can integrate reliably Correct answer.
Explanation
An API contract specifies the interface, including request and response formats, that consumers can rely on. Because services deploy independently, a stable, explicit contract is what allows them to evolve without breaking each other.
Question 8Software Development and Design
A team maintains a single repository containing application code, infrastructure definitions, and pipeline configuration. Which practice best supports consistent, reviewable changes to that repository?
- Requiring pull requests with peer review and automated checks before merge Correct answer.
- Disabling branch protection so maintainers can push urgent fixes
- Storing credentials in the repository so pipelines can authenticate
- Committing directly to the main branch to reduce merge overhead
Explanation
Pull requests with peer review and automated checks create a reviewable gate that catches defects and enforces standards before changes land. This is a core practice for maintaining quality in a shared repository.
Question 9Software Development and Design
An application consumes a third-party REST API that begins returning HTTP 429 responses. What is the most appropriate client behavior?
- Honor the Retry-After header and apply exponential backoff with jitter before retrying Correct answer.
- Treat the response as a permanent failure and disable the integration
- Switch to HTTP 200 by rewriting the response status in the client
- Immediately retry in a tight loop until a success response is received
Explanation
HTTP 429 indicates rate limiting, and the Retry-After header communicates how long to wait. Backoff with jitter avoids synchronized retry storms and respects the provider's limits.
Question 10Software Development and Design
A developer needs to add a required field to an existing public REST API without breaking current consumers. Which approach best follows backward-compatibility principles?
- Return the new field only for internal clients and document it as mandatory
- Change the data type of the new field in place without versioning
- Add the field as optional in a minor version and document its semantics Correct answer.
- Remove the existing response fields and reintroduce them under new names
Explanation
Adding an optional field is generally backward compatible because existing clients ignore unknown fields. Removing or retyping fields breaks consumers, so those changes require a new major version.
Question 11Software Development and Design
A logging component must be instantiated exactly once and shared across a process. Which pattern addresses this requirement, and what is a common criticism of it?
- Singleton, because it introduces global state that complicates testing Correct answer.
- Decorator, because it wraps the logger with additional behavior
- Observer, because it guarantees a single notification source
- Factory Method, because it hides constructor calls from clients
Explanation
The Singleton pattern restricts a class to one instance and provides a global access point, which suits a shared logger. Its main criticism is that the global state it introduces makes dependencies implicit and unit testing harder.
Question 12Software Development and Design
A code review finds a function that both validates input and writes records to a database. Which refactoring most improves the design?
- Add a boolean parameter that toggles whether validation runs
- Inline the validation into the database call to reduce function calls
- Extract validation into a separate function so each function has a single responsibility Correct answer.
- Wrap the function in a retry loop to handle validation failures
Explanation
Extracting validation gives each function one reason to change, improving readability and testability. Mixing validation with persistence couples unrelated concerns and makes both harder to test in isolation.
Question 13Software Development and Design
A team adopts test-driven development for a new module. Which sequence correctly describes the TDD cycle?
- Refactor production code first, then add tests only for code that proves difficult
- Write implementation, then write tests, then refactor the tests
- Write all tests for the module, then implement everything before running any test
- Write a failing test, make it pass with minimal code, then refactor while keeping tests green Correct answer.
Explanation
TDD follows a red-green-refactor cycle: write a test that fails, write just enough code to pass it, then refactor with the tests as a safety net. This keeps design driven by observable behavior.
Question 14Software Development and Design
An application must notify several independent subscribers whenever an order is placed, without the order service knowing their identities. Which pattern best fits?
- Builder
- Adapter
- Observer Correct answer.
- Proxy
Explanation
Observer defines a one-to-many dependency so that when a subject changes state, all registered observers are notified automatically. The order service stays decoupled from the concrete subscribers.
Question 15Software Development and Design
A CI pipeline should fail fast when a developer pushes code that breaks existing behavior. Which pipeline design best supports this?
- Run all stages in parallel regardless of dependencies to minimize total duration
- Run fast unit tests and static analysis first, then progressively slower integration and end-to-end stages Correct answer.
- Run the longest end-to-end tests first so failures surface early
- Skip automated tests and rely on manual QA after deployment
Explanation
Ordering stages from fastest to slowest gives quick feedback on the most common failures and avoids spending time on slow suites when basic checks already fail. This is the essence of fail-fast pipeline design.
Question 16Software Development and Design
What is the main benefit of using semantic versioning (MAJOR.MINOR.PATCH) for a library?
- It forces all consumers to upgrade on the same schedule
- It encodes the compatibility impact of a release so consumers can decide when to upgrade Correct answer.
- It guarantees that the library will never contain defects
- It replaces the need for a changelog or release notes
Explanation
Semantic versioning communicates intent: a MAJOR bump signals breaking changes, MINOR signals backward-compatible additions, and PATCH signals backward-compatible fixes. Consumers can therefore reason about upgrade risk.
Question 17Software Development and Design
A service must be tested against a third-party API that is unreliable and rate limited in the test environment. Which approach is most appropriate for the automated test suite?
- Use a test double or recorded stub that mimics the API contract Correct answer.
- Call the real API in every test run to maximize realism
- Increase the retry count until the real API eventually responds
- Disable the tests whenever the third party is unavailable
Explanation
A test double or recorded stub reproduces the API contract deterministically, keeping tests fast and independent of external availability. Contract tests can separately verify that the stub still matches the real API.
Question 18Software Development and Design
Which statement best explains why dependency injection improves testability?
- It compiles dependencies directly into the class to reduce runtime overhead
- It guarantees that integration tests are no longer needed
- It allows collaborators to be replaced with test doubles because dependencies are supplied from outside Correct answer.
- It prevents any class from depending on an interface
Explanation
Dependency injection passes collaborators into a class rather than having the class construct them internally. Tests can therefore substitute fakes or mocks, isolating the unit under test.
Question 19Software Development and Design
A monolithic application is being decomposed into microservices. Which criterion is most sound for deciding service boundaries?
- Align services with business capabilities and bounded contexts that can own their data Correct answer.
- Group code by the programming language each module is written in
- Split services so that each contains exactly one class
- Create one service per database table to maximize granularity
Explanation
Service boundaries work best when aligned with business capabilities and bounded contexts, because each service then owns a cohesive domain and its data. This minimizes cross-service coupling and distributed transactions.
Question 20Software Development and Design
A team wants to document an API so that both humans and tooling can consume the definition. Which approach best serves both audiences?
- A machine-readable specification such as OpenAPI that also generates human-readable documentation Correct answer.
- A prose wiki page that describes endpoints informally
- A screenshot gallery of example responses with no schema
- An email thread capturing decisions made during design
Explanation
A machine-readable specification like OpenAPI can drive tooling such as client generation and validation while also rendering human-readable docs. Informal prose or screenshots cannot be reliably consumed by tools.
Question 21Software Development and Design
A developer is asked to choose between a REST API and a GraphQL API for a mobile client that needs to minimize payload size across many varied screens. Which consideration most strongly favors GraphQL?
- GraphQL lets clients request exactly the fields they need, avoiding over-fetching Correct answer.
- GraphQL eliminates the need for authentication and authorization
- GraphQL requires fewer server resources because it never executes resolvers
- GraphQL guarantees faster database queries than REST
Explanation
GraphQL exposes a typed schema that lets clients select precisely the fields they need, which reduces over-fetching for varied client requirements. It does not inherently guarantee performance or remove security concerns.
Question 22Software Development and Design
A code review reveals that a module directly instantiates concrete classes from an external vendor library throughout its business logic. Which change most improves long-term maintainability?
- Increase the number of direct vendor calls so the dependency is easier to locate
- Copy the vendor library source into the repository and modify it in place
- Pin the vendor version forever and never upgrade it
- Introduce an abstraction layer that wraps the vendor library behind interfaces owned by the application Correct answer.
Explanation
Wrapping a third-party dependency behind application-owned interfaces isolates vendor details and makes future replacement or upgrade far easier. This is an application of the dependency inversion and adapter principles.
Question 23Software Development and Design
A distributed system uses an event-driven design in which producers publish domain events. Which property is most important to preserve when evolving event schemas over time?
- Every schema change must require all consumers to redeploy simultaneously
- Consumers must tolerate unknown fields and the schema must evolve additively within a version Correct answer.
- Events must embed the full internal database schema of the producer
- Producers should mutate past events in the log to match the newest schema
Explanation
Event schemas evolve safely when changes are additive and consumers ignore unknown fields, allowing independent deployment. Requiring synchronized redeploys or rewriting history breaks the decoupling that event-driven systems rely on.
Question 24Software Development and Design
A team is evaluating whether to adopt a new framework. Which evaluation practice best reduces long-term risk?
- Adopt it immediately in production to discover limitations under real load
- Choose it solely because it is the most recently released option
- Rely on marketing material from the vendor without independent testing
- Build a small proof of concept and assess maintainability, licensing, security posture, and community support Correct answer.
Explanation
A proof of concept combined with assessment of maintainability, licensing, security, and ecosystem health gives evidence-based insight into fit and risk. Immediate production adoption or vendor marketing alone exposes the team to avoidable risk.
Question 25Software Development and Design
An application must remain responsive while performing long-running background work. Which architectural approach best supports this while preserving reliability?
- Enqueue work to a durable queue processed by workers, with idempotent handlers and retries Correct answer.
- Perform the work synchronously in the request handler to simplify error handling
- Discard failed jobs silently to keep the queue moving
- Spawn an unbounded number of threads per request to maximize throughput
Explanation
Offloading work to a durable queue decouples request handling from processing and lets workers retry failures. Idempotent handlers ensure that retries do not duplicate side effects.
Question 26Software Development and Design
A team wants CI to reject any commit whose message does not follow the agreed format. Which Git mechanism is designed to enforce this locally before the commit is created?
- A server-side pre-receive hook on the remote
- A client-side commit-msg hook installed in the repository Correct answer.
- A .gitignore rule matching the commit message
- A branch protection rule requiring signed commits
Explanation
Client-side hooks such as commit-msg run on the developer's machine during git commit and can abort the operation when the message fails validation. Server-side hooks validate only after push, and neither .gitignore nor signature requirements inspect message format.
Question 27Software Development and Design
A developer must undo a commit that was already pushed to a shared branch, without rewriting published history. Which command accomplishes this?
- git commit --amend followed by a force push
- git reset --hard HEAD~1 followed by a force push
- git checkout <commit> and push the detached HEAD
- git revert <commit> followed by a normal push Correct answer.
Explanation
git revert creates a new commit that applies the inverse of the target commit, so history is preserved and other clones remain consistent. Rewriting history with reset or amend requires a force push that breaks collaborators who already pulled the branch.
Question 28Software Development and Design
Which practice best keeps a shared codebase's main branch continuously releasable when several developers integrate frequently?
- Manual merge reviews performed once per month
- Long-lived feature branches merged only at release time
- Trunk-based development with small, frequently merged changes and automated checks Correct answer.
- A freeze on the main branch during each sprint
Explanation
Trunk-based development keeps changes small and merges them often, and automated checks catch regressions immediately, so the main branch stays deployable. Long branches and freezes increase merge risk and delay feedback.
Question 29Software Development and Design
A team wants to enforce that no pull request merges unless all unit tests pass and at least one reviewer approves. Where should these rules be configured?
- In each developer's local Git configuration file
- In the repository's .gitattributes file
- In the commit-msg hook on the developer workstation
- In branch protection settings on the code hosting platform Correct answer.
Explanation
Branch protection rules on the hosting platform gate merges on required status checks and required approvals, and they apply to everyone regardless of local setup. Local configuration and hooks can be bypassed or differ per developer.
Question 30Software Development and Design
A library's public function is changed so that an existing parameter now has a different meaning, and no compatibility shim is provided. Following semantic versioning, which version increment is required?
- A MAJOR increment, because the change is backward incompatible Correct answer.
- A MINOR increment, because new behavior was added
- No increment, because semantic versioning applies only to applications
- A PATCH increment, because the function still exists
Explanation
Semantic versioning reserves MAJOR increments for backward-incompatible changes to the public API. Changing the meaning of an existing parameter breaks callers, so it is a breaking change regardless of whether the function signature looks the same.
Question 31Software Development and Design
An application must be packaged so that it runs identically on a developer laptop and in production, with all runtime dependencies pinned. Which approach best achieves this?
- A container image that pins base image and dependency versions Correct answer.
- A setup script that installs the latest dependencies at deploy time
- A wiki page listing the required runtime versions
- A virtual machine snapshot shared between environments
Explanation
A container image bundles the application with pinned dependencies and an immutable base, so the same artifact runs in every environment. Installing latest dependencies at deploy time or documenting versions leaves room for drift.
Question 32Software Development and Design
Which statement describes the role of an infrastructure-as-code state file?
- It records the mapping between declared resources and real infrastructure so changes can be planned. Correct answer.
- It encrypts secrets used by the deployment pipeline.
- It replaces the need for version control of infrastructure definitions.
- It stores application logs emitted during deployment.
Explanation
The state file tracks which real resources correspond to the declared configuration, enabling tools to compute a diff and plan changes. It is not a log store, a secret manager, or a substitute for version control.
Question 33Software Development and Design
A team reviews a change that adds a new public method to a widely used class. Which review criterion is most relevant to preserving backward compatibility?
- Whether existing callers continue to compile and behave unchanged Correct answer.
- Whether the change increases the file's line count
- Whether the method is placed at the end of the class
- Whether the method name follows the team's naming convention
Explanation
Backward compatibility hinges on existing consumers continuing to work without modification, so the review should verify that current callers are unaffected. Naming, placement, and size are style concerns that do not determine compatibility.
Question 34Software Development and Design
A service's configuration currently lives in code and differs per environment. Which refactoring most improves portability across environments?
- Adding conditional statements that detect the hostname
- Hardcoding all values to the production settings
- Duplicating the codebase for each environment
- Externalizing environment-specific values into configuration injected at runtime Correct answer.
Explanation
Externalizing configuration separates environment-specific values from the artifact, so the same build runs anywhere with injected settings. Duplicated codebases, hardcoded production values, and hostname detection all increase coupling and risk.
Question 35Software Development and Design
A developer needs to design a REST endpoint that returns a large collection that clients page through. Which design is most consistent with REST conventions?
- Expose pagination through query parameters with links to next and previous pages Correct answer.
- Encode the page number in the request body of a GET
- Return the entire collection in one response regardless of size
- Require clients to guess resource identifiers sequentially
Explanation
Pagination via query parameters with hypermedia links for next and previous pages is the conventional REST approach and keeps responses bounded. Returning everything, guessing identifiers, or sending a body with GET all violate expected semantics.
Question 36Software Development and Design
A team must decide whether to adopt a new open-source library. Which evaluation step best reduces long-term risk?
- Choosing the library with the most stars on its repository page
- Adopting it immediately and evaluating after production rollout
- Checking only that the library installs successfully
- Reviewing license terms, maintenance activity, and security advisory history Correct answer.
Explanation
License compatibility, active maintenance, and a track record of handling security advisories are the factors that determine whether a dependency remains safe and supportable. Installation success or popularity alone does not address those risks.
Question 37Software Development and Design
A service must remain available when a downstream dependency becomes slow. Which design most directly prevents a slow dependency from exhausting the caller's resources?
- Retrying failed calls indefinitely with no delay
- Caching the dependency's responses permanently
- Increasing the caller's thread pool without bound
- Applying a timeout and circuit breaker around calls to the dependency Correct answer.
Explanation
Timeouts bound how long a caller waits, and a circuit breaker stops sending traffic to a failing dependency so resources are not consumed by stalled calls. Unbounded pools, unlimited retries, and permanent caching either worsen exhaustion or serve stale data.
Question 38Software Development and Design
A team wants to detect a regression introduced by a dependency upgrade before merging. Which practice best provides that signal?
- Assuming PATCH upgrades are always safe
- Waiting for users to report failures after release
- Running the existing automated test suite against the upgraded dependency in CI Correct answer.
- Reviewing the dependency's changelog only
Explanation
Executing the automated suite against the upgraded dependency in CI produces direct evidence of behavioral regressions before merge. Changelogs and version-number assumptions are useful context but do not verify the team's own code paths.
Question 39Software Development and Design
A codebase has grown so that a single build takes hours. Which decomposition approach best shortens feedback time while preserving correctness?
- Splitting the repository into independently buildable modules with their own pipelines Correct answer.
- Removing tests from the pipeline to reduce runtime
- Building only on release days
- Disabling caching to keep builds reproducible
Explanation
Splitting into independently buildable modules lets each pipeline build and test only what changed, which shortens feedback while keeping coverage. Removing tests or building rarely trades correctness or feedback for speed.
Question 40Software Development and Design
Which artifact should be produced by a CI pipeline so that the exact tested binary can be promoted to production without rebuilding?
- A versioned, immutable build artifact stored in a registry Correct answer.
- A branch name recorded in a spreadsheet
- A screenshot of the passing test report
- A fresh build performed separately in each environment
Explanation
Promoting the same immutable, versioned artifact that was tested ensures production runs exactly what passed CI. Rebuilding per environment or tracking metadata manually breaks that guarantee.
Question 41Using APIs
A developer calls a REST API and receives HTTP status 429. Which client behavior best follows API consumption best practice?
- Resend the request with a larger page size to reduce call count
- Treat the response as a permanent failure and stop all further calls
- Retry immediately in a tight loop until the request succeeds
- Honor the Retry-After header and apply exponential backoff with jitter Correct answer.
Explanation
429 Too Many Requests signals rate limiting, and servers commonly return a Retry-After header indicating how long to wait. A well-behaved client waits at least that long and adds exponential backoff with jitter so retries do not synchronize across many clients.
Question 42Using APIs
Which HTTP method is defined as safe and idempotent, meaning repeated identical requests should produce the same server state?
- CONNECT
- POST
- PUT Correct answer.
- PATCH
Explanation
PUT replaces the target resource with the enclosed representation, so repeating the same request yields the same state. POST is neither safe nor idempotent, PATCH is not guaranteed idempotent, and CONNECT is a tunneling method.
Question 43Using APIs
An API returns a JSON body containing a hypermedia link to the next page of results. Which API style does this most directly illustrate?
- gRPC with protobuf contracts
- GraphQL with a single endpoint
- SOAP with WSDL binding
- HATEOAS-driven hypermedia Correct answer.
Explanation
Embedding links that tell the client which transitions are available is the hypermedia constraint, often called HATEOAS. The client discovers next actions from the payload rather than hardcoding URLs.
Question 44Using APIs
What is the primary purpose of the Accept header in an HTTP request?
- To specify the media types the client is willing to receive Correct answer.
- To authenticate the client to the API gateway
- To request a compressed transfer encoding
- To declare the media type of the request body being sent
Explanation
Accept performs content negotiation, telling the server which response media types the client can handle. The request body type is declared with Content-Type, and compression is negotiated with Accept-Encoding.
Question 45Using APIs
Which HTTP status code indicates that a resource was successfully created as a result of the request?
- 201 Correct answer.
- 200
- 204
- 302
Explanation
201 Created confirms a new resource now exists, and the response often includes a Location header pointing to it. 200 is a generic success, 204 means success with no body, and 302 is a redirect.
Question 46Using APIs
A client must send credentials over a REST API. Which practice best protects them in transit?
- Embed the token in the request body as plain text over HTTP
- Place the token in the URL query string for easy logging
- Send the token in the Authorization header over TLS Correct answer.
- Store the token in a cookie without the Secure attribute
Explanation
Bearer or basic credentials belong in the Authorization header and must travel over TLS so intermediaries cannot read them. Tokens in URLs leak into logs and browser history, and unencrypted transport exposes them to interception.
Question 47Using APIs
Which API architectural style is defined by a formal contract in a WSDL document and typically uses XML envelopes?
- REST
- SOAP Correct answer.
- WebSocket
- GraphQL
Explanation
SOAP services publish a WSDL contract describing operations and message formats and exchange XML envelopes. REST is resource-oriented without a WSDL, GraphQL uses a schema and query language, and WebSocket is a full-duplex transport.
Question 48Using APIs
A REST API returns a 404 status for a collection endpoint that the client knows exists. Which interpretation is most accurate?
- The requested resource path does not match any resource on the server Correct answer.
- The server encountered an internal error while processing
- The server is throttling the client and will retry automatically
- The client must resend the request with different credentials
Explanation
404 Not Found means the server cannot map the request URI to an existing resource. Throttling uses 429, authentication failures use 401 or 403, and internal errors use 5xx codes.
Question 49Using APIs
A client paginates through a large collection that changes frequently. Which approach best avoids skipped or duplicated records?
- Offset pagination with a fixed page size and no ordering
- Cursor or keyset pagination based on a stable sort key Correct answer.
- Randomly sampling pages until the count matches
- Requesting all records in a single unpaginated call
Explanation
Cursor or keyset pagination anchors the next page to a stable value such as an ID or timestamp, so inserts and deletes do not shift rows across page boundaries. Offset pagination drifts when the underlying data changes.
Question 50Using APIs
Which OAuth 2.0 grant is appropriate for a machine-to-machine integration with no end user present?
- Authorization code with PKCE
- Client credentials grant Correct answer.
- Implicit grant
- Resource owner password grant
Explanation
The client credentials grant lets a confidential client authenticate directly to the authorization server and obtain a token for its own identity. It is designed for server-to-server calls without a user context.