[{"id":"grpcintermediate-001","courseId":"grpc-intermediate","domain":"message-schema","topic":"oneof members","prompt":"A serialized message sets two members of the same oneof. Put these steps the parser takes for each oneof member it reads from the wire, in order.","hint":"Think about how the parser keeps a oneof down to one live member.","explain":"One message can mention a group of alternatives several times. Each mention is handled in stages against what the reader already holds, and the stages touch different things.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"sort","items":[{"text":"Read the next field from the wire, starting at the beginning of the data.","why":"Parsing begins at the first byte and handles one value at a time."},{"text":"Clear any other member of the same oneof that is already set.","why":"Before the value is stored, a rival member of the oneof is removed so only one case stays set."},{"text":"Apply the value as though the field were not in a oneof.","why":"Once rivals are gone, the value is handled like a regular singular field."},{"text":"A primitive overwrites the stored value; a message merges into it.","why":"This is the outcome of applying the value: the field's kind decides between replacing and merging."}]},"options":[],"answer":"o:abcd","explanation":"On the wire, a oneof field first clears any other set member of its oneof, then is applied like a plain field: a primitive overwrites the stored value and a message merges into it.","concept":"On the wire, a oneof field first clears any other set member of its oneof, then is applied like a plain field: a primitive overwrites the stored value and a message merges into it.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["On the wire, only the last member of a oneof seen by the parser survives parsing."]},{"id":"grpcintermediate-002","courseId":"grpc-intermediate","domain":"message-schema","topic":"Explicit presence with optional","prompt":"In proto3, a singular int32 field declared without the optional label still records whether it was set, even when its value is 0.","hint":"Consider what a zero value means when nothing records that the field was set.","explain":"Presence is a record of whether a field was set, kept apart from its value. Proto3 does not keep that record for every field alike, and the label you choose changes what code can ask.","source":"https://protobuf.dev/programming-guides/field_presence/","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Without the optional label, proto3 does not track presence for numeric fields, so 0 looks the same as not set."},{"id":"b","text":"False","why":"A numeric field without optional keeps no presence record, so a 0 cannot be told apart from an unset value."}],"answer":"b","explanation":"In proto3, singular numeric fields without the optional label do not track presence; optional gives them explicit presence, with has-methods and serialized zeros.","concept":"In proto3, singular numeric fields without the optional label do not track presence; optional gives them explicit presence, with has-methods and serialized zeros.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Use optional on proto3 scalars when a zero value must differ from an unset one."]},{"id":"grpcintermediate-003","courseId":"grpc-intermediate","domain":"message-schema","topic":"Presence of message fields","prompt":"A proto3 file declares the two fields below with no optional labels. Which statement about presence in the generated API is correct?","hint":"Compare how the two declared types differ in what the generated code can check.","explain":"Whether a field keeps a record of having been set depends on its type and on the syntax rules in force. Fields in one message can differ on this point, so judge each declaration by its own type.","source":"https://protobuf.dev/programming-guides/field_presence/","interaction":{"type":"single"},"options":[{"id":"a","text":"home has presence and zip does not.","why":"A singular message keeps explicit presence without the optional label; a numeric field without it does not."},{"id":"b","text":"Both have presence, since proto3 tracks presence for every field type.","whyNot":"Proto3 does not track presence for basic types unless they are declared optional."},{"id":"c","text":"Neither has presence, since proto3 never tracks presence without optional.","whyNot":"Singular message fields track presence in proto3 even without the optional label."},{"id":"d","text":"zip has presence, but home needs optional before it can have any.","whyNot":"The label is not needed for message fields; it is what gives numeric fields like zip presence."}],"answer":"a","explanation":"In proto3, singular message fields track presence even without the optional label, while singular numeric fields without optional do not.","concept":"In proto3, singular message fields track presence even without the optional label, while singular numeric fields without optional do not.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"syntax = \"proto3\";\nmessage Person {\n  Address home = 1;\n  int32 zip = 2;\n}","takeaways":["Message fields in proto3 expose presence by default; scalar fields need optional to do so."]},{"id":"grpcintermediate-004","courseId":"grpc-intermediate","domain":"message-schema","topic":"Map key type restrictions","prompt":"A teammate indexes orders by price with the declaration below. Which statement about this field is correct?","hint":"Think about which kinds of scalar are excluded from the lookup position.","explain":"Each entry pairs a lookup value with content, so the language must decide which types are eligible for the lookup role. Anything outside the eligible list is left out.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"single"},"options":[{"id":"a","text":"It is invalid: floating-point types cannot be map keys.","why":"Map key types are limited to integral and string scalars, and floating-point types are excluded."},{"id":"b","text":"It is valid, since any scalar type can serve as a map key.","whyNot":"Only integral and string scalars are allowed as keys; bytes and floats are excluded."},{"id":"c","text":"It is invalid, because a map key cannot be a number of any kind.","whyNot":"Integral numbers are allowed as keys; only floating-point types are excluded."},{"id":"d","text":"It is valid, because bytes is the only scalar type that keys reject.","whyNot":"Floating-point types are excluded too, so bytes is not the only rejected scalar."}],"answer":"a","explanation":"A map key_type must be an integral or string scalar; floating-point types, bytes, enums and messages cannot be keys.","concept":"A map key_type must be an integral or string scalar; floating-point types, bytes, enums and messages cannot be keys.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"map<double, Order> orders = 1;","takeaways":["Choose int or string types for map keys; floats, bytes, enums and messages are rejected."]},{"id":"grpcintermediate-005","courseId":"grpc-intermediate","domain":"message-schema","topic":"Map iteration order","prompt":"Looping over a proto3 map field in generated code always yields its entries in ascending key order, so code may depend on that order.","hint":"Consider which orderings a protobuf map promises, and which output format sorts.","explain":"A serialized form can impose its own sorting on the entries it writes, and that is separate from the order a collection hands back when you walk it. Ask which of those a guarantee covers.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Map iteration order is undefined, so code cannot rely on any key order when it loops over a map."},{"id":"b","text":"False","why":"Text-format output is sorted by key, but looping over the map in generated code carries no ordering promise."}],"answer":"b","explanation":"Protobuf leaves map iteration order undefined; only text-format generation sorts maps by key, so code must not depend on iteration order.","concept":"Protobuf leaves map iteration order undefined; only text-format generation sorts maps by key, so code must not depend on iteration order.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Never rely on the iteration order of a protobuf map; sort keys yourself if order matters."]}]