YANG choice statement: one branch selected from multiple alternatives
Short answer
A A YANG choice groups multiple alternative branches and permits only one, such as one case, container, or leaf, to be selected in a valid instance.
Question
Key Takeaways
A YANG choice statement is a schema-level selector that groups alternative branches and allows only one branch to exist in a valid instance. The correct answer is A because that mutual-exclusion rule matches selecting one node from multiple options, not the behavior of a list, container, or leaf. The choice itself is never serialized; only the selected case's node appears in the XML or JSON payload.
Expert Analysis
A YANG choice statement is a schema-level selection point that groups alternative branches and allows only one branch to be present, so the description that matches it is the one that says a single node is selected from multiple options.
Choice enforces a single-branch selection across alternative nodes
The defining property is mutual exclusion: a choice collects alternatives and a valid instance may contain nodes from only one of them. The alternatives are normally case statements, although a leaf, container, list, leaf-list, or anydata can serve as shorthand for a case with the same name. The choice contributes no value, key, or parent element of its own; it contributes a rule about which branch may be populated. That is why “selects one node from multiple options” is the accurate summary, and why a choice element does not appear in encoded XML or JSON. A device model might separate an IPv4 address branch from an IPv6 address branch, or a static route branch from a dynamic route branch, and a payload supplying both is invalid. The rule concerns the set of instantiated nodes, not their order. A branch can contain several child nodes when a case holds a container or a list, so “one node” means one alternative branch rather than necessarily one scalar leaf. The schema makes that exclusivity explicit, allowing tools to reject conflicting configuration before it reaches the device.
Resolution happens in the schema, so no choice wrapper appears in a payload
When a management tool builds XML for NETCONF or JSON for RESTCONF, it chooses the branch by emitting the selected case's node and its descendants; it never emits a choice or case element. Validation at that step compares the instantiated nodes against the schema and rejects a second branch from the same choice. The choice's substatements control edge cases: mandatory true requires a branch to be chosen, a default case supplies a fallback when the client omits the choice, and when can make the whole selection conditional. The default case does not create a container in the data tree; it only identifies which case is assumed when no node from the choice is present. Pyang and YANG Suite expose the structure in a tree view, where choice and case are visible as schema nodes despite never being serialized. The practical test is to inspect the payload: if an element named after the choice were required, every choice would add an artificial container to the data tree, which would break existing models and make the encoded form depend on schema-only metadata. The absence of that wrapper is exactly what lets a choice switch between dissimilar shapes—an address leaf, a route container, or a list—without changing the identity of the selected data.
List, container, and leaf each lose the exclusivity requirement
A list is a repeatable collection of entries, usually keyed, and its purpose is to hold multiple instances rather than to choose one alternative, so selecting B would describe a data-node aggregation that can coexist with siblings. A container is a grouping parent for child nodes and is itself a node in the data tree, so selecting C would describe a structural wrapper that can exist alongside other containers instead of an either/or rule. A leaf is a scalar data node with a type and a value, so selecting D would describe a single value holder that has no notion of alternative branches at all. Each of these statements can appear inside a case, which is exactly why they are tempting: a choice may contain a leaf branch and a container branch, or a list branch and a leaf branch, but the leaf, list, or container is the selected content, not the selector. The selector is the choice statement that names and organizes the cases. Confusing the content with the selection mechanism changes the validation result: a schema with only a leaf permits that leaf to be set, while a schema with a choice between two leaves permits exactly one of them. The options describe building blocks; only choice carries the mutual-exclusion semantics.
A grouping-only container would win only without mutual exclusion
A container would be the right description if the construct merely grouped related child nodes under one parent and allowed those children to coexist with any sibling structure the model permits. That condition would hold for a YANG container used to organize an interface's settings, for example, where the container's presence is independent of another interface settings container. It is not met here because the construct being described has alternatives and enforces that at most one alternative is instantiated; that either/or behavior is the entire point, and a plain container has no mechanism for rejecting a second branch. The distinction also explains why a choice cannot simply be replaced by a container with optional children: optional children can all be present at once, while cases are mutually exclusive. A list would become the better answer only if the alternatives were repeatable entries identified by keys and multiple entries could coexist; a leaf would become the better answer only if the construct were a scalar value with no branching. None of those conditions applies to a schema node whose stated job is to select one option from several.
Official Reference
https://www.rfc-editor.org/rfc/rfc7950.html#section-7.9
This link opens the official vendor documentation in a new tab.
Exam Strategy
For YANG terminology items, classify each option by schema role before matching the wording: leaf, list, and container define data nodes, while choice and case organize alternatives. If the stem describes a single active branch or a radio-button-style selection, choose choice, not the node types that can appear inside its cases. Build a quick mental map of statement to purpose and use the option's own noun to eliminate mismatches.
Related Analysis
Practice All 300-435 Questions
Access 150 questions with complete answers and detailed explanations.
View Full 300-435 Practice Test →