DevNet Associate study materials
DevNet Associate study resources

DevNet Associate practice questions

One question at a time. Build your DevNet Associate understanding.

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

In Python, what does json.loads() return for the JSON text {"host": "r1", "port": 22}?

  1. A string containing the original JSON text
  2. A dictionary with the keys host and port Correct answer.
  3. A tuple of alternating keys and values
  4. A list holding the two values in order

Explanation

json.loads() deserializes JSON text into native Python objects. A JSON object maps to a dict, JSON arrays map to lists, and JSON strings, numbers, and booleans map to their Python equivalents. Keys are converted to strings and values to matching Python types.

Question 2Software Development and Design

A developer needs a local working copy of a remote Git repository including its full commit history. Which command accomplishes this?

  1. git clone <url> Correct answer.
  2. git init <url>
  3. git pull <url>
  4. git fetch <url>

Explanation

git clone copies the remote repository, its objects, and its history into a new local directory and sets up a remote named origin. It is the standard way to obtain a working copy for the first time.

Question 3Software Development and Design

In YAML, how is the nesting of mappings and sequences primarily expressed?

  1. By semicolon termination
  2. By indentation Correct answer.
  3. By closing tags
  4. By braces and brackets only

Explanation

YAML uses indentation to express hierarchy, and the amount of indentation must be consistent within a block. It also supports optional flow style with braces and brackets, but block style indentation is the defining characteristic.

Question 4Software Development and Design

Which statement about a Python tuple is accurate?

  1. It can hold only string values
  2. It cannot be changed after it is created Correct answer.
  3. It is unordered and cannot be indexed
  4. Its elements can be reassigned in place

Explanation

A tuple is an immutable ordered sequence, so its length and element references are fixed once the tuple is created. Elements are accessed by integer index just like a list, and a tuple may hold values of any type.

Question 5Software Development and Design

Which characteristic describes the waterfall software development model?

  1. Two-week iterative delivery cycles
  2. Test-first development of each function
  3. Sequential phases with little backtracking Correct answer.
  4. Pair programming on every task

Explanation

Waterfall organizes work into distinct phases such as requirements, design, implementation, and testing that are completed in order. Because each phase is expected to be finished before the next begins, revisiting earlier phases is expensive and discouraged.

Question 6Software Development and Design

In a REST API, which HTTP method is conventionally used to retrieve a representation of a resource?

  1. PATCH
  2. GET Correct answer.
  3. DELETE
  4. POST

Explanation

GET is defined as a safe, read-only method that returns a representation of the addressed resource. It should not change server state, which distinguishes it from POST, DELETE, and PATCH.

Question 7Software Development and Design

Which built-in Python type represents an unordered collection of unique elements with no associated values?

  1. The list type
  2. The tuple type
  3. The set type Correct answer.
  4. The dict type

Explanation

A set stores unique, hashable elements with no defined order and no mapped values, which makes membership tests fast. Duplicate insertions are silently ignored.

Question 8Software Development and Design

Which Git command reports which files are staged, modified, or untracked in the working tree?

  1. git show
  2. git log
  3. git status Correct answer.
  4. git diff

Explanation

git status summarizes the state of the working tree and the index, including staged changes, unstaged modifications, and untracked files. It is the standard command for deciding what to add or commit next.

Question 9Software Development and Design

What does git pull do by default when run on a tracking branch?

  1. Fetches the remote and merges into the current branch Correct answer.
  2. Discards uncommitted local changes in the working tree
  3. Creates a new local branch from the remote default branch
  4. Uploads local commits to the remote tracking branch

Explanation

git pull is a convenience command that runs a fetch followed by a merge of the fetched upstream commits into the current branch. Using the rebase option changes the second step to a rebase instead of a merge.

Question 10Software Development and Design

A merge stops and asks the developer to resolve conflicts. Which condition caused this?

  1. Both branches changed the same lines in incompatible ways Correct answer.
  2. The local branch has no upstream tracking branch configured
  3. Both branches used identical commit messages
  4. The repository has no remote configured

Explanation

Git merges automatically when changes touch different regions, but when the same lines were modified on both branches it cannot choose a result. It marks the conflicted hunks in the files and pauses the merge for manual resolution.

Question 11Software Development and Design

Which sequence describes the standard test-driven development cycle?

  1. Write a failing test, make it pass, then refactor Correct answer.
  2. Write all tests at the end of the development sprint
  3. Refactor, then design, then deploy
  4. Write code, then write tests that match it

Explanation

TDD follows the red-green-refactor rhythm: add a small test that fails, write the minimum code to make it pass, then improve the design while keeping tests green. The test is written before the production code, which drives the design.

Question 12Software Development and Design

Which property best describes a unit test?

  1. It exercises a small unit of code in isolation Correct answer.
  2. It exercises the entire system end to end with real devices
  3. It requires a live connection to a production network
  4. It runs only after the code has been deployed

Explanation

A unit test targets one small, well-defined piece of behavior such as a single function or method. External dependencies are usually replaced with test doubles so the test stays fast, repeatable, and independent of other tests.

Question 13Software Development and Design

What is refactoring?

  1. Adding new features requested by users
  2. Fixing a defect that was reported in production
  3. Rewriting the entire application in a different programming language
  4. Improving internal structure without changing behavior Correct answer.

Explanation

Refactoring reorganizes code to improve readability, reduce duplication, or simplify design while preserving observable behavior. A good safety net of automated tests is what makes refactoring verifiable.

Question 14Software Development and Design

In the model-view-controller pattern, which component renders the user interface and presents data to the user?

  1. Router
  2. View Correct answer.
  3. Controller
  4. Model

Explanation

The view is responsible for presentation and for displaying data supplied by the model. It should not contain business logic, which keeps presentation changes from affecting data handling.

Question 15Software Development and Design

What problem does the singleton pattern solve?

  1. It restricts a class to a single instance Correct answer.
  2. It notifies dependents when state changes
  3. It creates families of related objects without naming classes
  4. It converts one interface into another

Explanation

The singleton pattern guarantees that exactly one instance of a class exists and provides a well-known access point to it. It is used for shared resources such as a configuration registry or a connection pool.

Question 16Software Development and Design

A monitoring tool must notify many subscriber modules whenever an interface state changes, without hard-coding the list of subscribers. Which pattern fits best?

  1. Singleton
  2. Adapter
  3. Observer Correct answer.
  4. Factory method

Explanation

The observer pattern defines a one-to-many dependency in which subscribers register with a subject and are notified automatically when the subject changes. Subscribers can be added or removed at runtime without modifying the subject's code.

Question 17Software Development and Design

Which statement about a stateless RESTful API is accurate?

  1. Each request carries all the information needed Correct answer.
  2. Clients must wrap every payload in a SOAP envelope
  3. Resources cannot be addressed by unique URIs
  4. The server keeps a session record for every connected client

Explanation

Statelessness means the server does not retain per-client session context between requests; any state needed to process a call is included in the request itself. This makes horizontal scaling and retries simpler.

Question 18Software Development and Design

A REST API successfully creates a new resource. Which HTTP status code is most appropriate for the response?

  1. 201 Created Correct answer.
  2. 204 No Content
  3. 400 Bad Request
  4. 200 OK

Explanation

201 Created indicates that the request succeeded and resulted in a new resource, and the response often includes a Location header identifying it. It distinguishes creation from a generic successful read or update.

Question 19Software Development and Design

What is the purpose of a try/except block in Python?

  1. To handle runtime errors raised in the try block Correct answer.
  2. To repeat a block of statements a fixed number of times
  3. To import modules only when a condition is true
  4. To define a class that inherits from another class

Explanation

Code that may raise an exception is placed in the try suite, and matching except clauses define how the program recovers. This allows a program to respond to errors instead of terminating with a traceback.

Question 20Software Development and Design

A continuous integration pipeline runs the automated test suite on every push. What is the main benefit?

  1. It removes the need for peer code review
  2. It guarantees that the product ships with no defects
  3. It finds integration problems early in the cycle Correct answer.
  4. It replaces the staging environment entirely

Explanation

Frequent automated builds and tests detect broken integrations shortly after the change is introduced, when the cause is easy to identify. Fixing problems early is far cheaper than discovering them late in the release cycle.

Question 21Software Development and Design

Consider this Python code: def add(item, bucket=[]): bucket.append(item) return bucket print(add(1)) print(add(2)) What is printed?

  1. [1, 2] then [1, 2]
  2. [1] then [2]
  3. [1] then [1, 2] Correct answer.
  4. A TypeError is raised on the second call

Explanation

Default argument values are evaluated once when the function is defined, so the same list object is reused across calls. The first call appends 1 and returns [1], and the second appends 2 to that same list, giving [1, 2].

Question 22Software Development and Design

What does git rebase do to the commits of a feature branch when run against the main branch?

  1. It copies the main branch files over the feature branch files
  2. It deletes the feature branch commits from the repository
  3. It creates a merge commit that joins both histories together
  4. It replays branch commits onto a new base with new hashes Correct answer.

Explanation

Rebase takes each commit unique to the feature branch and reapplies it on top of the new base commit. Because the parent changes, each replayed commit receives a new hash, producing a linear history.

Question 23Software Development and Design

Which statement correctly compares the idempotency of the PUT and POST methods?

  1. POST is idempotent, while PUT is not
  2. Both PUT and POST are idempotent
  3. Neither PUT nor POST is idempotent
  4. PUT is idempotent, while POST is generally not Correct answer.

Explanation

An idempotent method produces the same server state whether the request is sent once or repeated. PUT replaces the addressed resource with the supplied representation, so repeats converge, whereas repeated POST requests typically create additional resources.

Question 24Software Development and Design

Which problem is the factory method pattern intended to solve?

  1. Attaching additional responsibilities to an object dynamically
  2. Ensuring that only one instance of a class ever exists
  3. Creating objects without naming concrete classes in client code Correct answer.
  4. Converting the interface of a class into another interface

Explanation

Factory method defines an interface for creating an object but lets subclasses or a factory function decide which concrete class is instantiated. Client code depends on the abstraction, which makes it easier to introduce new implementations.

Question 25Software Development and Design

Why do unit tests commonly replace a call to a remote API with a mock object?

  1. To avoid writing any assertions in the test
  2. To confirm that the production server is reachable
  3. To keep the test fast, isolated, and deterministic Correct answer.
  4. To raise the code coverage of deployment scripts

Explanation

A mock returns controlled responses, so the test does not depend on network availability, latency, or remote data that may change. This isolates the unit under test and makes pass or fail results reproducible.

Question 26Software Development and Design

A developer needs every teammate to install identical package versions for a Python project using pip. Which file is conventionally used to record those pinned dependencies?

  1. .gitignore
  2. Dockerfile
  3. requirements.txt Correct answer.
  4. Makefile

Explanation

pip reads a plain-text requirements file and installs the listed packages; entries written with == pin exact versions so every environment resolves the same set. This file is committed alongside the source so teammates can run a single install command and get reproducible results.

Question 27Software Development and Design

Which Git command creates a new local branch and immediately makes it the current branch?

  1. git clone -b new-feature
  2. git tag -b new-feature
  3. git branch new-feature
  4. git checkout -b new-feature Correct answer.

Explanation

The -b flag tells checkout to create the branch and switch the working tree to it in one operation, which is why it is the usual way to start feature work. Creating a branch without switching leaves the developer on the previous branch.

Question 28Software Development and Design

Consider this Python code: def add_tag(tags): tags.append('new') return tags labels = ['a', 'b'] result = add_tag(labels) After it runs, what are labels and result?

  1. labels and result are two separate lists
  2. labels stays ['a', 'b'] and result is ['a', 'b', 'new']
  3. labels stays ['a', 'b'] and result is None
  4. labels becomes ['a', 'b', 'new']; result points to it Correct answer.

Explanation

Python passes the reference to the existing list object into the function, so append mutates the caller's list in place. The returned value is that same object, meaning labels and result both refer to one list containing 'new'.

Question 29Software Development and Design

An API receives a request carrying an access token that has expired. The client is expected to obtain a fresh token and retry. Which HTTP status code best expresses this response?

  1. 404 Not Found
  2. 403 Forbidden
  3. 401 Unauthorized Correct answer.
  4. 400 Bad Request

Explanation

401 signals that the request lacks valid authentication credentials for the target resource, which covers missing, malformed, or expired tokens. The response can carry a WWW-Authenticate header telling the client how to authenticate again.

Question 30Software Development and Design

A Python function body contains a yield statement. What happens at the moment the function is called?

  1. It returns None until a for loop iterates over the call
  2. It runs the body up to the first yield and returns that value
  3. It returns a generator object without running the body Correct answer.
  4. It runs the body fully and stores all yielded values in memory

Explanation

Any function containing yield is a generator function; calling it only constructs a generator object and executes no statements. The body runs lazily, resuming at each yield when the consumer requests the next item with next() or a for loop.

Question 31Understanding and Using APIs

Which HTTP method is designed to retrieve a representation of a resource without changing server state?

  1. POST
  2. GET Correct answer.
  3. DELETE
  4. PUT

Explanation

GET is defined as a safe method: it requests a representation of the target resource and should not alter server state. POST, PUT, and DELETE are all capable of modifying resources.

Question 32Understanding and Using APIs

A client requests a resource that does not exist on the server. Which status code is most appropriate for the response?

  1. 200
  2. 500
  3. 302
  4. 404 Correct answer.

Explanation

404 Not Found indicates the server understood the request but no resource exists at that URI. It is a client-side error in the 4xx class.

Question 33Understanding and Using APIs

Which pair of characters encloses a JSON object?

  1. [ ]
  2. { } Correct answer.
  3. < >
  4. ( )

Explanation

In JSON, curly braces delimit an object, which is an unordered set of name/value pairs. Square brackets delimit an array instead.

Question 34Understanding and Using APIs

Which HTTP status code range indicates that a request was successfully processed?

  1. 3xx
  2. 2xx Correct answer.
  3. 4xx
  4. 1xx

Explanation

Codes in the 2xx range confirm that the server received, understood, and accepted the request. The other ranges report informational, redirect, and error outcomes.

Question 35Understanding and Using APIs

Which HTTP method is most appropriate for adding a new item to a collection where the server assigns the new identifier?

  1. GET
  2. OPTIONS
  3. POST Correct answer.
  4. HEAD

Explanation

POST to a collection URI asks the server to create a subordinate resource and assign its identifier, which is returned in the Location header. The other methods are safe and do not create resources.

Question 36Understanding and Using APIs

What is the primary purpose of an API key?

  1. To define the response format returned by the server
  2. To cache responses so repeated calls run faster
  3. To identify and authenticate the calling application Correct answer.
  4. To encrypt the request body while it is in transit

Explanation

An API key is a credential that identifies the calling application to the API so the provider can authenticate it and apply quotas or permissions. It does not provide transport security or negotiate response formats.

Question 37Understanding and Using APIs

In a URL, which character begins the query string?

  1. #
  2. ? Correct answer.
  3. &
  4. :

Explanation

The question mark separates the path from the query string, and individual parameters inside it are separated by ampersands. A hash starts a fragment, which is not sent to the server.

Question 38Understanding and Using APIs

A request carries the header Content-Type: application/json. What does this header describe?

  1. The encoding of the body the client is sending Correct answer.
  2. The format the client wants the server to return
  3. The authentication scheme required by the server
  4. The API version the client is requesting

Explanation

Content-Type tells the recipient how to interpret the body of the message that carries it. For a request, that means the representation the client is sending, not the one it expects back.

Question 39Understanding and Using APIs

Which statement about HTTP idempotency is correct?

  1. Repeating the same PUT request leaves the server in the same state Correct answer.
  2. GET is not idempotent because it changes server state
  3. Repeating the same POST request always creates exactly one resource
  4. DELETE is never idempotent because the resource is removed

Explanation

An idempotent method can be applied repeatedly with the same resulting server state. PUT replaces the resource with the supplied representation, so repeating it converges on the same state.

Question 40Understanding and Using APIs

Which status code indicates that a request succeeded and a new resource was created?

  1. 201 Created Correct answer.
  2. 204 No Content
  3. 200 OK
  4. 202 Accepted

Explanation

201 Created reports that the request succeeded and a new resource now exists, usually identified by the Location header. It differs from generic success codes by explicitly confirming creation.

Question 41Understanding and Using APIs

A request presents a token that has expired. Which status code is most appropriate?

  1. 403 Forbidden
  2. 400 Bad Request
  3. 401 Unauthorized Correct answer.
  4. 405 Method Not Allowed

Explanation

401 Unauthorized signals that the request lacks valid authentication credentials, which includes an expired or invalid token, and it is normally paired with a WWW-Authenticate header. 403 is reserved for a caller who is authenticated but not permitted.

Question 42Understanding and Using APIs

How do the PUT and PATCH methods differ when updating a resource?

  1. PUT applies a partial update; PATCH replaces the whole representation
  2. PUT creates a resource; PATCH deletes an existing resource
  3. PUT and PATCH are both safe methods that never modify state
  4. PUT replaces the whole representation; PATCH applies a partial update Correct answer.

Explanation

PUT sends a complete representation that replaces the resource, so omitted fields are lost. PATCH sends only the changes to apply, leaving unmentioned fields intact.

Question 43Understanding and Using APIs

Which statement correctly pairs a model-driven management protocol with its transport and encoding?

  1. RESTCONF uses SSH as its transport and YAML as its encoding
  2. NETCONF uses HTTP as its transport and JSON as its encoding
  3. RESTCONF uses SNMP as its transport and XML as its encoding
  4. NETCONF uses SSH as its transport and XML as its encoding Correct answer.

Explanation

NETCONF runs over a secure SSH session and encodes its operations and data in XML. RESTCONF instead reuses HTTP methods with JSON or XML payloads.

Question 44Understanding and Using APIs

How does HTTP Basic authentication carry the username and password?

  1. Encrypted with the API key before being placed in the body
  2. Base64-encoded in the Authorization header Correct answer.
  3. Hashed with SHA-256 and sent in a custom header
  4. Sent as plain text query parameters in the request URL

Explanation

Basic authentication joins the username and password with a colon and Base64-encodes the result in the Authorization header. Base64 is reversible encoding, so confidentiality depends entirely on TLS.

Question 45Understanding and Using APIs

An API that returns large collections supports pagination. What do the limit and offset query parameters control?

  1. The number of records to return and where to start Correct answer.
  2. The authentication scope and the rate limit applied
  3. The response format and the API version requested
  4. The request timeout and the automatic retry count

Explanation

Pagination parameters let a client fetch a collection in chunks: limit caps the page size and offset sets the starting position. Together they allow predictable iteration over a large result set.

Question 46Understanding and Using APIs

How is an OAuth 2.0 access token normally presented to a protected API?

  1. In the URL path, replacing the resource identifier
  2. In the body of every request as a JSON field named token
  3. In the Authorization header as a Bearer token Correct answer.
  4. In the HTTP method name, replacing the usual GET verb

Explanation

Bearer tokens are sent in the Authorization header using the scheme name Bearer followed by the token value. Any party holding the token can use it, which is why TLS is mandatory.

Question 47Understanding and Using APIs

A client receives status code 429 from an API. What does this indicate?

  1. The server crashed while handling the request
  2. The requested resource was not found on the server
  3. The client must authenticate before the request is processed
  4. The client exceeded its rate limit and should back off Correct answer.

Explanation

429 Too Many Requests means the caller has hit a throttling limit. Well-behaved clients read Retry-After and retry after a delay, ideally with exponential backoff.

Question 48Understanding and Using APIs

An endpoint is published at https://api.example.com/v2/devices. What does the /v2 path segment represent?

  1. The second device in the collection of devices
  2. The API version, allowing breaking changes Correct answer.
  3. The number of requests allowed per second
  4. The TLS protocol version required by the server

Explanation

Placing the version in the URI lets providers run multiple incompatible API revisions side by side so existing clients keep working. The client simply targets the revision it was written against.

Question 49Understanding and Using APIs

Which statement describes YAML syntax correctly?

  1. Nested structures cannot be represented at all
  2. Every key must be enclosed in angle brackets and quoted
  3. Keys and values must be separated by semicolons
  4. Indentation defines structure; hyphens mark list items Correct answer.

Explanation

YAML relies on indentation to express nesting and uses a leading hyphen for each sequence entry. This makes it compact and readable but sensitive to whitespace errors.

Question 50Understanding and Using APIs

How does a webhook deliver event notifications?

  1. The server calls a client URL when an event occurs Correct answer.
  2. The client asks the server for updates at fixed intervals
  3. The server holds events until the client opens a socket
  4. The client sends its credentials before each event occurs

Explanation

A webhook is a reverse API call: the client registers a callback URL and the server issues an HTTP request to it whenever the event fires. This avoids the latency and wasted requests of polling.