Cisco CCNP Enterprise 350-401 ENCOR Python Interpretation and JSON Construction Practice Test

 

Topic 19 covers python interpretation and json construction for the Cisco Certified Specialist – Enterprise Core certification. These original practice questions apply the verified 350-401 objectives to practical decisions and troubleshooting. Select one answer unless a fixed number is requested. For broader preparation, visit the Cisco 350-401 ENCOR Exam Dumps page. Each option includes an explanation of the relevant behavior and scenario constraints.

Question 1

Given `devices = [“R1”, “R2”, “R3”]`, what does `print(devices[1])` output?

  1. 1
  2. IndexError
  3. R3
  4. R1
  5. R2

Correct Answer: E

 

Correct Answer

Answer E is correct because Python lists use zero-based indexing, so index 1 is the second element.

Incorrect Answers

Answer A is incorrect because the expression returns the element, not the index.

Answer B is incorrect because index 1 exists in a three-element list. It does not satisfy the stem’s governing point: Python sequence indexes start at zero.

Answer C is incorrect because R3 is index 2. It does not satisfy the stem’s governing point: Python sequence indexes start at zero.

Answer D is incorrect because R1 is index 0. It does not satisfy the stem’s governing point: Python sequence indexes start at zero.

 

Question 2

Given `device = {“name”:”R1″, “role”:”edge”}`, which expression returns `edge`?

  1. Key subscript: device[“role”]
  2. Value-as-key subscript: device[“edge”]
  3. Numeric subscript: device[1]
  4. Call syntax: device(“role”)
  5. Attribute syntax: device.role

Correct Answer: A

 

Correct Answer

Answer A is correct because the value is retrieved by the string key role.

Incorrect Answers

Answer B is incorrect because edge is a value, not a key. It does not satisfy the stem’s governing point: Dictionary values are retrieved by key, not by list-style position.

Answer C is incorrect because a dictionary is keyed by its keys, not positional index 1.

Answer D is incorrect because a dictionary is not called like a function for key lookup.

Answer E is incorrect because plain dictionaries do not expose keys as attributes.

 

Question 3

A script receives `count = “12”` from an API field and executes `count = int(count); print(count + 3)`. What is printed?

  1. 3
  2. 15
  3. TypeError
  4. 123
  5. 12

Correct Answer: B

 

Correct Answer

Answer B is correct because int(“12”) produces integer 12, then 3 is added numerically.

Incorrect Answers

Answer A is incorrect because the original converted value is included. It does not satisfy the stem’s governing point: Convert numeric text to an integer before arithmetic when the value is supplied as a string.

Answer C is incorrect because the explicit conversion removes the string/integer type mismatch.

Answer D is incorrect because that would result from string concatenation, but the value was converted to int.

Answer E is incorrect because the addition changes the value. It does not satisfy the stem’s governing point: Convert numeric text to an integer before arithmetic when the value is supplied as a string.

 

Question 4

Consider `a = [“R1”]; b = a; b.append(“R2”); print(a)`. What is the output?

  1. [“R1”, “R2”]
  2. NameError
  3. None
  4. [“R1”]
  5. [“R2”]

Correct Answer: A

 

Correct Answer

Answer A is correct because append mutates the shared list object referenced by both a and b.

Incorrect Answers

Answer B is incorrect because both variables are defined. It does not satisfy the stem’s governing point: Assignment of a mutable list binds another name to the same object unless a copy is made.

Answer C is incorrect because append returns None, but the code prints a, not the append return.

Answer D is incorrect because b does not receive an independent copy; both names reference the same list.

Answer E is incorrect because append does not replace the original element. It does not satisfy the stem’s governing point: Assignment of a mutable list binds another name to the same object unless a copy is made.

 

Question 5

What happens when Python evaluates `”10″ + 5` with no explicit conversion?

  1. It produces “105”.
  2. It produces 15.
  3. It produces 10.
  4. It produces 5.
  5. It raises TypeError.

Correct Answer: E

 

Correct Answer

Answer E is correct because string and integer operands are incompatible for + without conversion.

Incorrect Answers

Answer A is incorrect because concatenation would require both operands to be strings.

Answer B is incorrect because Python does not implicitly convert the string to an integer for this addition.

Answer C is incorrect because the second operand is not ignored. It does not satisfy the stem’s governing point: Python does not silently add a string and integer; convert to compatible types explicitly.

Answer D is incorrect because the first operand is not ignored. It does not satisfy the stem’s governing point: Python does not silently add a string and integer; convert to compatible types explicitly.

 

Question 6

What does this code print? `x=7
if x>10: print(“A”)
elif x>5: print(“B”)
else: print(“C”)`

  1. B
  2. Nothing
  3. C
  4. A
  5. A then B

Correct Answer: A

 

Correct Answer

Answer A is correct because the first test is false and the elif test 7>5 is true.

Incorrect Answers

Answer B is incorrect because one branch is true. It does not satisfy the stem’s governing point: An if/elif/else chain executes the first true branch only.

Answer C is incorrect because else is skipped after a true elif. It does not satisfy the stem’s governing point: An if/elif/else chain executes the first true branch only.

Answer D is incorrect because 7 is not greater than 10. It does not satisfy the stem’s governing point: An if/elif/else chain executes the first true branch only.

Answer E is incorrect because only the first matching branch in the chain executes.

 

Question 7

What values are printed by `for i in range(1,4): print(i)`?

  1. 1, 4
  2. 2, 3, 4
  3. 1, 2, 3, 4
  4. 0, 1, 2, 3
  5. 1, 2, 3

Correct Answer: E

 

Correct Answer

Answer E is correct because range includes the start and excludes the stop value.

Incorrect Answers

Answer A is incorrect because range generates each integer in between. It does not satisfy the stem’s governing point: Python range(start, stop) includes start and excludes stop.

Answer B is incorrect because the loop begins at 1. It does not satisfy the stem’s governing point: Python range(start, stop) includes start and excludes stop.

Answer C is incorrect because 4 is the exclusive stop. It does not satisfy the stem’s governing point: Python range(start, stop) includes start and excludes stop.

Answer D is incorrect because the explicit start is 1. It does not satisfy the stem’s governing point: Python range(start, stop) includes start and excludes stop.

 

Question 8

What is printed? `for d in [“R1″,”R2″,”R3″]:
if d==”R2”: break
print(d)`

  1. R1 only
  2. R2 only
  3. R1 and R2
  4. Nothing
  5. R1, R2, R3

Correct Answer: A

 

Correct Answer

Answer A is correct because the loop prints R1, then break terminates the loop when d is R2.

Incorrect Answers

Answer B is incorrect because R1 is printed before the break condition is reached.

Answer C is incorrect because break occurs before the print for R2. It does not satisfy the stem’s governing point: break terminates the nearest loop immediately, so later iterations and statements after the break in that iteration are skipped.

Answer D is incorrect because R1 does not satisfy the break condition. It does not satisfy the stem’s governing point: break terminates the nearest loop immediately, so later iterations and statements after the break in that iteration are skipped.

Answer E is incorrect because break prevents later iterations. It does not satisfy the stem’s governing point: break terminates the nearest loop immediately, so later iterations and statements after the break in that iteration are skipped.

 

Question 9

What is printed? `for d in [“R1″,”R2″,”R3″]:
if d==”R2”: continue
print(d)`

  1. R2 only
  2. R1 and R3
  3. R1 only
  4. Nothing
  5. R1, R2, R3

Correct Answer: B

 

Correct Answer

Answer B is correct because continue skips the rest of the R2 iteration, then processing resumes with R3.

Incorrect Answers

Answer A is incorrect because the continue branch prevents R2 from reaching print.

Answer C is incorrect because continue does not terminate the entire loop. It does not satisfy the stem’s governing point: continue skips the remainder of the current iteration but does not end the loop.

Answer D is incorrect because R1 and R3 both reach print. It does not satisfy the stem’s governing point: continue skips the remainder of the current iteration but does not end the loop.

Answer E is incorrect because R2 is skipped. It does not satisfy the stem’s governing point: continue skips the remainder of the current iteration but does not end the loop.

 

Question 10

A record is included only when `device[“up”] and device[“role”] == “edge”` is true. Which record is included?

  1. Any record with a role field
  2. `{“up”: True, “role”:”core”}`
  3. `{“up”: True, “role”:”edge”}`
  4. `{“up”: False, “role”:”core”}`
  5. `{“up”: False, “role”:”edge”}`

Correct Answer: C

 

Correct Answer

Answer C is correct because both Boolean requirements are true. This directly matches the stem’s governing point: The Boolean `and` expression requires both link state and role criteria to be true.

Incorrect Answers

Answer A is incorrect because both conditions must be satisfied. It does not satisfy the stem’s governing point: The Boolean `and` expression requires both link state and role criteria to be true.

Answer B is incorrect because role is not edge. It does not satisfy the stem’s governing point: The Boolean `and` expression requires both link state and role criteria to be true.

Answer D is incorrect because neither requirement is true. It does not satisfy the stem’s governing point: The Boolean `and` expression requires both link state and role criteria to be true.

Answer E is incorrect because the first operand is false. It does not satisfy the stem’s governing point: The Boolean `and` expression requires both link state and role criteria to be true.

 

Question 11

Given `def label(name, role): return name + “:” + role`, what does `label(“R1″,”edge”)` return?

  1. R1role
  2. TypeError
  3. None
  4. R1:edge
  5. edge:R1

Correct Answer: D

 

Correct Answer

Answer D is correct because the two supplied arguments are concatenated with the literal colon.

Incorrect Answers

Answer A is incorrect because the literal colon and supplied role are both used.

Answer B is incorrect because two parameters receive two string arguments. It does not satisfy the stem’s governing point: Function arguments bind to parameters in the supplied order unless keywords or other parameter rules change that mapping.

Answer C is incorrect because the function contains an explicit return. It does not satisfy the stem’s governing point: Function arguments bind to parameters in the supplied order unless keywords or other parameter rules change that mapping.

Answer E is incorrect because the function uses name before role. It does not satisfy the stem’s governing point: Function arguments bind to parameters in the supplied order unless keywords or other parameter rules change that mapping.

 

Question 12

Consider `def f(): print(“R1”)
x=f(); print(x)`. What is the observable output?

  1. TypeError
  2. R1 followed by None
  3. R1 only
  4. None followed by R1
  5. R1 followed by R1

Correct Answer: B

 

Correct Answer

Answer B is correct because print emits R1; a function with no return statement returns None, which is then printed.

Incorrect Answers

Answer A is incorrect because assigning a None return is valid. It does not satisfy the stem’s governing point: Printing a value inside a function does not return it; a function without an explicit return yields None.

Answer C is incorrect because the caller also prints the return value. It does not satisfy the stem’s governing point: Printing a value inside a function does not return it; a function without an explicit return yields None.

Answer D is incorrect because the function body runs before the caller prints x.

Answer E is incorrect because printing inside the function is not the same as returning the string.

 

Question 13

What does this code print? `x=”global”
def f():
x=”local”
return x
print(f()); print(x)`

  1. NameError
  2. global then global
  3. global then local
  4. local then local
  5. local then global

Correct Answer: E

 

Correct Answer

Answer E is correct because the assignment inside f creates a local x and does not replace the outer x.

Incorrect Answers

Answer A is incorrect because both scopes have a defined x. It does not satisfy the stem’s governing point: A variable assigned inside a function is local by default, so it can differ from the outer variable of the same name.

Answer B is incorrect because f returns its local value. It does not satisfy the stem’s governing point: A variable assigned inside a function is local by default, so it can differ from the outer variable of the same name.

Answer C is incorrect because the order and scoping do not produce this result.

Answer D is incorrect because the outer x remains unchanged. It does not satisfy the stem’s governing point: A variable assigned inside a function is local by default, so it can differ from the outer variable of the same name.

 

Question 14

Given `def retry(count=3): return count*2`, what does `retry()` return?

  1. TypeError
  2. None
  3. 6
  4. 2
  5. 3

Correct Answer: C

 

Correct Answer

Answer C is correct because omitting the argument uses default count=3, then returns 3*2.

Incorrect Answers

Answer A is incorrect because a default value makes the argument optional. It does not satisfy the stem’s governing point: A default argument is used when the caller omits that parameter.

Answer B is incorrect because the function explicitly returns a value. It does not satisfy the stem’s governing point: A default argument is used when the caller omits that parameter.

Answer D is incorrect because the default is 3, not 1. It does not satisfy the stem’s governing point: A default argument is used when the caller omits that parameter.

Answer E is incorrect because the function multiplies count by 2. It does not satisfy the stem’s governing point: A default argument is used when the caller omits that parameter.

 

Question 15

A function is `def get_name(d): d[“name”]` and the caller executes `name=get_name({“name”:”R1″}); print(name)`. What prints?

  1. TypeError
  2. None
  3. KeyError
  4. name
  5. R1

Correct Answer: B

 

Correct Answer

Answer B is correct because without an explicit return, the function returns None.

Incorrect Answers

Answer A is incorrect because dictionary key access is valid. It does not satisfy the stem’s governing point: A function that computes a value but omits `return` yields None to its caller.

Answer C is incorrect because the name key exists. It does not satisfy the stem’s governing point: A function that computes a value but omits `return` yields None to its caller.

Answer D is incorrect because the key name is not printed literally. It does not satisfy the stem’s governing point: A function that computes a value but omits `return` yields None to its caller.

Answer E is incorrect because the expression is evaluated but not returned. It does not satisfy the stem’s governing point: A function that computes a value but omits `return` yields None to its caller.

 

Question 16

Given `inventory={“device”:{“name”:”R1″,”mgmt”:{“ip”:”10.0.0.1″}}}`, which expression returns `10.0.0.1`?

  1. Top-level key lookup: inventory[“ip”]
  2. Nested key lookup: inventory[“device”][“mgmt”][“ip”]
  3. Shallow device lookup: inventory[“device”][“ip”]
  4. Attribute chain: inventory.device.mgmt.ip
  5. Numeric indexing: inventory[0][1][2]

Correct Answer: B

 

Correct Answer

Answer B is correct because the expression follows the supplied nested dictionary hierarchy.

Incorrect Answers

Answer A is incorrect because ip is nested below device and mgmt. It does not satisfy the stem’s governing point: Read nested API-like dictionaries by following each supplied key in the actual hierarchy.

Answer C is incorrect because ip is not directly under device. It does not satisfy the stem’s governing point: Read nested API-like dictionaries by following each supplied key in the actual hierarchy.

Answer D is incorrect because plain dictionaries do not provide this attribute chain.

Answer E is incorrect because the structure is dictionaries, not positional nested lists.

 

Question 17

Given `ifs=[{“name”:”Gi1″,”up”:True},{“name”:”Gi2″,”up”:False},{“name”:”Gi3″,”up”:True}]`, which expression produces `[“Gi1″,”Gi3”]`?

  1. `[i[“name”] for i in ifs if i[“up”]]`
  2. `[i[“name”] for i in ifs if not i[“up”]]`
  3. `[i[“up”] for i in ifs]`
  4. `[“Gi1″,”Gi2″,”Gi3”]`
  5. `ifs[“name”]`

Correct Answer: A

 

Correct Answer

Answer A is correct because the comprehension selects names only for records whose up value is true.

Incorrect Answers

Answer B is incorrect because this selects Gi2. It does not satisfy the stem’s governing point: A list comprehension can filter records and project the desired field in one expression.

Answer C is incorrect because this returns Boolean values, not names. It does not satisfy the stem’s governing point: A list comprehension can filter records and project the desired field in one expression.

Answer D is incorrect because that does not filter on up state. It does not satisfy the stem’s governing point: A list comprehension can filter records and project the desired field in one expression.

Answer E is incorrect because ifs is a list, not a dictionary keyed by name.

 

Question 18

What is printed? `d={“name”:”R1″}
try:
print(d[“site”])
except KeyError:
print(“unknown”)`

  1. R1
  2. site
  3. unknown
  4. None
  5. The script terminates before printing.

Correct Answer: C

 

Correct Answer

Answer C is correct because the missing site key raises KeyError, which the except block handles.

Incorrect Answers

Answer A is incorrect because the code looks up site, not name. It does not satisfy the stem’s governing point: Dictionary subscription of a missing key raises KeyError; a matching handler can supply controlled fallback behavior.

Answer B is incorrect because the missing key name is not returned. It does not satisfy the stem’s governing point: Dictionary subscription of a missing key raises KeyError; a matching handler can supply controlled fallback behavior.

Answer D is incorrect because dictionary subscription raises rather than returning None for a missing key.

Answer E is incorrect because the matching exception handler prevents termination. It does not satisfy the stem’s governing point: Dictionary subscription of a missing key raises KeyError; a matching handler can supply controlled fallback behavior.

 

Question 19

A script is intended to call `push(device)` once for each device that is down. Which indentation does that? Assume `devices` is a list of dictionaries with `up`.

  1. `for d in devices:
    if not d[“up”]:
    push(d)`
  2. `for d in devices: pass`
  3. `for d in devices:
    if not d[“up”]:
    pass
    push(d)`
  4. `for d in devices:
    push(d)
    if not d[“up”]: pass`
  5. `if not devices[0][“up”]:
    for d in devices: push(d)`

Correct Answer: A

 

Correct Answer

Answer A is correct because push is nested under both the loop and the condition, so it runs once per down device.

Incorrect Answers

Answer B is incorrect because no API action occurs. It does not satisfy the stem’s governing point: Indentation defines the execution block; a per-device conditional action must be nested inside both loop and condition.

Answer C is incorrect because push runs only once after the loop using the last d.

Answer D is incorrect because push runs for every device, not only down devices.

Answer E is incorrect because one first-device test can trigger pushes for all devices.

 

Question 20

What does this code print with no assumptions about external systems? `devices=[“R1″,”R2”]; result=[]
for d in devices: result.append(d.lower())
print(result)`

  1. External-inventory claim: The current live router inventory.
  2. Connection-error claim: A connection error.
  3. Lowercase result: `[“r1”, “r2”]`
  4. Original-case result: `[“R1”, “R2”]`
  5. In-place-mutation claim: Nothing because lower() mutates in place.

Correct Answer: C

 

Correct Answer

Answer C is correct because the script lowercases each supplied string and appends it locally.

Incorrect Answers

Answer A is incorrect because the code never queries a network or file.

Answer B is incorrect because there is no network call. It does not satisfy the stem’s governing point: Interpret only the supplied code and data; do not invent external state or network effects that the script does not perform.

Answer D is incorrect because lower() returns lowercase strings. It does not satisfy the stem’s governing point: Interpret only the supplied code and data; do not invent external state or network effects that the script does not perform.

Answer E is incorrect because strings are immutable and lower() returns a new string that is appended.

 

Question 21

Which text is valid JSON for an object whose key is `name` and value is `R1`?

  1. Array-with-equals form: `[“name”=”R1”]`
  2. Unquoted object: `{name: R1}`
  3. Single-quoted object: {‘name’: ‘R1’}
  4. Double-quoted JSON object: `{“name”: “R1”}`
  5. Arrow notation: `name -> R1`

Correct Answer: D

 

Correct Answer

Answer D is correct because both the member name and string value use valid JSON string syntax.

Incorrect Answers

Answer A is incorrect because JSON arrays do not use equals signs for named members.

Answer B is incorrect because JSON object member names and string values require double quotes.

Answer C is incorrect because single quotes are Python-like but not valid JSON string delimiters.

Answer E is incorrect because this is not JSON object syntax. It does not satisfy the stem’s governing point: JSON object member names are strings and JSON strings use double quotation marks.

 

Question 22

Which is a valid JSON Boolean field?

  1. JSON Boolean: `{“enabled”: true}`
  2. Yes literal: `{“enabled”: yes}`
  3. Uppercase Boolean: `{“enabled”: TRUE}`
  4. String value: `{“enabled”: “true”}`
  5. Python-style Boolean: `{“enabled”: True}`

Correct Answer: A

 

Correct Answer

Answer A is correct because JSON Boolean true is lowercase. This directly matches the stem’s governing point: JSON Boolean literal names are lowercase `true` and `false`.

Incorrect Answers

Answer B is incorrect because yes is not a JSON literal. It does not satisfy the stem’s governing point: JSON Boolean literal names are lowercase `true` and `false`.

Answer C is incorrect because uppercase TRUE is not a JSON literal. It does not satisfy the stem’s governing point: JSON Boolean literal names are lowercase `true` and `false`.

Answer D is incorrect because this is valid JSON but the value is a string, not a Boolean.

Answer E is incorrect because JSON literal names are lowercase; True is Python syntax.

 

Question 23

Which corrected payload removes the syntax error from `{“name”:”R1″,}`?

  1. Single-quoted trailing form: {‘name’:’R1′,}
  2. Double-comma form: `{“name”:”R1″,,}`
  3. Bare-null member form: `{“name”:”R1″, null}`
  4. No trailing separator: `{“name”:”R1″}`
  5. Semicolon form: `{“name”:”R1″;}`

Correct Answer: D

 

Correct Answer

Answer D is correct because removing the trailing member separator produces a valid one-member object.

Incorrect Answers

Answer A is incorrect because single quotes and trailing comma are not valid JSON syntax.

Answer B is incorrect because two commas remain invalid. It does not satisfy the stem’s governing point: Standard JSON does not allow a trailing comma after the final object member.

Answer C is incorrect because a bare value is not a name/value member.

Answer E is incorrect because semicolon is not the JSON member separator. It does not satisfy the stem’s governing point: Standard JSON does not allow a trailing comma after the final object member.

 

Question 24

A payload needs an ordered JSON list of three interface names. Which representation is correct?

  1. Numeric-key object: `{“0″:”Gi1″,”1″:”Gi2″,”2″:”Gi3”}`
  2. Curly-brace value set: `{“Gi1″,”Gi2″,”Gi3”}`
  3. Parenthesized tuple-like form: `(“Gi1″,”Gi2″,”Gi3”)`
  4. Single comma-delimited string: `”Gi1,Gi2,Gi3″`
  5. JSON array: `[“Gi1″,”Gi2″,”Gi3”]`

Correct Answer: E

 

Correct Answer

Answer E is correct because square brackets represent a JSON array of values.

Incorrect Answers

Answer A is incorrect because this is an object, not the requested array.

Answer B is incorrect because curly braces represent an object, which requires name/value pairs.

Answer C is incorrect because parentheses are not JSON array syntax. It does not satisfy the stem’s governing point: Use a JSON array, enclosed in square brackets, for an ordered sequence of values.

Answer D is incorrect because this is one string rather than three array elements.

 

Question 25

The required string value is `R1 says “up”`. Which JSON fragment correctly encodes it?

  1. Array-equals form: `[“msg”=”R1 says up”]`
  2. Escaped-inner-quote JSON: `{“msg”:”R1 says \”up\””}`
  3. Unescaped-inner-quote JSON: `{“msg”:”R1 says “up””}`
  4. Unquoted-value form: `{“msg”:R1 says up}`
  5. Single-quoted form: {‘msg’:’R1 says “up”‘}

Correct Answer: B

 

Correct Answer

Answer B is correct because the embedded quotation marks are escaped within the JSON string.

Incorrect Answers

Answer A is incorrect because this is not JSON object syntax. It does not satisfy the stem’s governing point: Quotation marks inside a JSON string must be escaped so they are not interpreted as string delimiters.

Answer C is incorrect because unescaped inner quotes terminate the string. It does not satisfy the stem’s governing point: Quotation marks inside a JSON string must be escaped so they are not interpreted as string delimiters.

Answer D is incorrect because string values require quotes. It does not satisfy the stem’s governing point: Quotation marks inside a JSON string must be escaped so they are not interpreted as string delimiters.

Answer E is incorrect because single-quoted member syntax is not standard JSON. It does not satisfy the stem’s governing point: Quotation marks inside a JSON string must be escaped so they are not interpreted as string delimiters.

 

Question 26

A supplied API schema says `”timeout”` is an integer. Which payload matches that type?

  1. Numeric timeout: `{“timeout”:30}`
  2. Boolean timeout: `{“timeout”:true}`
  3. Null timeout: `{“timeout”:null}`
  4. String timeout: `{“timeout”:”30″}`
  5. Array timeout: `{“timeout”:[30]}`

Correct Answer: A

 

Correct Answer

Answer A is correct because 30 is a JSON number and matches the integer requirement.

Incorrect Answers

Answer B is incorrect because Boolean is a different JSON type. It does not satisfy the stem’s governing point: JSON can represent numbers independently of strings; match the type required by the supplied schema.

Answer C is incorrect because null is not an integer unless the schema explicitly permits it.

Answer D is incorrect because 30 is encoded as a JSON string. It does not satisfy the stem’s governing point: JSON can represent numbers independently of strings; match the type required by the supplied schema.

Answer E is incorrect because the value is an array, not an integer.

 

Question 27

A field is explicitly present but has no value. The schema permits JSON null. Which fragment represents that state?

  1. Python None: `{“site”: None}`
  2. String null: `{“site”: “null”}`
  3. Uppercase NULL: `{“site”: NULL}`
  4. Missing value: `{“site”: }`
  5. JSON null: `{“site”: null}`

Correct Answer: E

 

Correct Answer

Answer E is correct because null is the JSON literal for an absent/no-value representation.

Incorrect Answers

Answer A is incorrect because None is Python syntax, not a JSON literal.

Answer B is incorrect because this is the string null, not the null value.

Answer C is incorrect because JSON literals are lowercase. It does not satisfy the stem’s governing point: Use the JSON literal `null` when the schema permits an explicit no-value value.

Answer D is incorrect because a value is syntactically required after the colon.

 

Question 28

A schema requires `interfaces` to be an array of objects, each with `name` and `enabled`. Which payload has the correct outer type and element structure?

  1. Object-valued interfaces: `{“interfaces”:{“name”:”Gi1″,”enabled”:true}}`
  2. Array-root wrapper: `[{“interfaces”:”Gi1″}]`
  3. Array-of-object interfaces: `{“interfaces”:[{“name”:”Gi1″,”enabled”:true}]}`
  4. String-valued interfaces: `{“interfaces”:”Gi1″}`
  5. Array-of-primitives interfaces: `{“interfaces”:[“Gi1”,true]}`

Correct Answer: C

 

Correct Answer

Answer C is correct because interfaces is an array containing an object with the required fields.

Incorrect Answers

Answer A is incorrect because interfaces is an object, not the required array.

Answer B is incorrect because the outer structure and field types do not match the stated schema.

Answer D is incorrect because interfaces is a string. It does not satisfy the stem’s governing point: Distinguish a JSON array from a JSON object and preserve the element type required by the supplied schema.

Answer E is incorrect because the array elements are primitives rather than interface objects.

 

Question 29

A request schema requires `{“device”:{“mgmt”:{“ip”:<string>}}}`. Which payload preserves that hierarchy?

  1. Array-replaced hierarchy: `{“device”:[“mgmt”,”10.0.0.1″]}`
  2. Device-with-IP object: `{“device”:{“ip”:”10.0.0.1″}}`
  3. Required nested hierarchy: `{“device”:{“mgmt”:{“ip”:”10.0.0.1″}}}`
  4. Reversed hierarchy: `{“mgmt”:{“device”:{“ip”:”10.0.0.1″}}}`
  5. Flat IP object: `{“ip”:”10.0.0.1″}`

Correct Answer: C

 

Correct Answer

Answer C is correct because the payload follows device > mgmt > ip exactly.

Incorrect Answers

Answer A is incorrect because the required nested objects are replaced by an array.

Answer B is incorrect because the mgmt level is missing. It does not satisfy the stem’s governing point: A syntactically valid payload still must preserve the hierarchy required by the API schema.

Answer D is incorrect because the hierarchy is reversed. It does not satisfy the stem’s governing point: A syntactically valid payload still must preserve the hierarchy required by the API schema.

Answer E is incorrect because the required device and mgmt containers are missing.

 

Question 30

An API requires fields `name` (string) and `enabled` (Boolean). Which payload is syntactically valid JSON but violates the supplied field requirement?

  1. Boolean false field: `{“name”:”R1″,”enabled”:false}`
  2. Different name value: `{“name”:”R2″,”enabled”:true}`
  3. Extra site field: `{“name”:”R1″,”enabled”:true,”site”:”A”}`
  4. String true field: `{“name”:”R1″,”enabled”:”true”}`
  5. Boolean true field: `{“name”:”R1″,”enabled”:true}`

Correct Answer: D

 

Correct Answer

Answer D is correct because the JSON is syntactically valid, but enabled is a string instead of the required Boolean.

Incorrect Answers

Answer A is incorrect because this matches the required types. It does not satisfy the stem’s governing point: JSON syntax validity is different from schema validity; a value may parse correctly but have the wrong required type.

Answer B is incorrect because the specific name value can differ unless constrained further.

Answer C is incorrect because the extra field is not stated as forbidden; the required fields still match.

Answer E is incorrect because this matches both field names and types. It does not satisfy the stem’s governing point: JSON syntax validity is different from schema validity; a value may parse correctly but have the wrong required type.

Popular posts

img