[{"id":"grpcbeginner-001","courseId":"grpc-beginner","domain":"message-schema","topic":"Package names","prompt":"Your file says package foo.bar; and defines message Open. You generate C++ code from it. Where does the generated Open class live?","hint":"Think about what the package directive changes in the generated C++ code.","explain":"A package name is a prefix that keeps a message's full name unique across files. Each code generator maps that prefix onto the scoping construct its own language uses.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"single"},"options":[{"id":"a","text":"In the C++ namespace foo::bar","why":"The C++ generator wraps the classes in a namespace, and for package foo.bar that namespace is foo::bar."},{"id":"b","text":"In the global C++ namespace, since C++ ignores packages","whyNot":"Python and Go ignore the package directive, but C++ uses it as the namespace."},{"id":"c","text":"In a C++ namespace named Open","whyNot":"The message name becomes the class name; the package decides the namespace."},{"id":"d","text":"In a C++ namespace named foo_bar","whyNot":"The package becomes a nested namespace written with ::, not an underscore name."}],"answer":"a","explanation":"The C++ generator wraps generated classes in a namespace built from the package, so message Open in package foo.bar is in foo::bar.","concept":"The C++ generator wraps generated classes in a namespace built from the package, so message Open in package foo.bar is in foo::bar.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"package foo.bar;\n\nmessage Open {\n  string id = 1;\n}","takeaways":["The package directive sets where generated code lives, and that depends on the language."]},{"id":"grpcbeginner-002","courseId":"grpc-beginner","domain":"message-schema","topic":"Default values of singular fields","prompt":"In proto3, a singular int32 field that is set to 0 is still written into the serialized bytes.","hint":"Think about what happens to a value that equals the type's default.","explain":"A parser that finds no bytes for a field returns its default. Proto3 scalar fields keep no flag saying whether they were set, so a reader cannot tell an explicit default from a missing field.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"A scalar field set to its default is not put on the wire, so the 0 never appears in the bytes."},{"id":"b","text":"False","why":"Protobuf leaves a scalar field that holds its default off the wire, so the 0 is not serialized."}],"answer":"b","explanation":"In proto3, a scalar field set to its default value is not serialized on the wire.","concept":"In proto3, a scalar field set to its default value is not serialized on the wire.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Scalar fields holding their default cost nothing on the wire in proto3."]},{"id":"grpcbeginner-003","courseId":"grpc-beginner","domain":"message-schema","topic":"Enum zero value","prompt":"You write a proto3 enum for a search field. What must the first value listed in that enum satisfy?","hint":"Think about what a numeric field holds when nothing was set.","explain":"A numeric field always holds some number, so the protocol needs one value that stands for 'not set' and acts as the default. Look closely at what the first entry of the enum has to be.","source":"https://protobuf.dev/programming-guides/proto3/","interaction":{"type":"single"},"options":[{"id":"a","text":"It must have the number zero.","why":"Zero is the numeric default, and proto3 requires the first value to be zero so that default is a valid enum value."},{"id":"b","text":"It can be any number, since proto3 has no defaults.","whyNot":"Proto3 does have defaults; the first value must be zero so that 0 can serve as the numeric default."},{"id":"c","text":"It must be numbered one, because zero is reserved.","whyNot":"Zero is required for the first value in proto3, not reserved against use."},{"id":"d","text":"It must be the largest number in the enum.","whyNot":"The first listed value, not the largest, must be zero."}],"answer":"a","explanation":"In proto3 the first value in an enum must be zero, because zero is the numeric default for enum fields.","concept":"In proto3 the first value in an enum must be zero, because zero is the numeric default for enum fields.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["In proto3 an enum's first listed value must be zero; name it like _UNSPECIFIED."]},{"id":"grpcbeginner-004","courseId":"grpc-beginner","domain":"message-schema","topic":"Enum value naming","prompt":"You are naming the values of a new enum in a protobuf file. Which TWO naming rules from the style guide should you follow?","hint":"Two rules cover how the value names are cased and what the first entry is called.","explain":"Protobuf identifiers follow fixed casing styles that depend on what kind of name they are. Enum values also have a naming convention for the entry that serves as the fallback when nothing is set.","source":"https://protobuf.dev/programming-guides/style/","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Value names are written in UPPER_SNAKE_CASE.","why":"The style guide says enum value names use UPPER_SNAKE_CASE, while enum type names use TitleCase."},{"id":"b","text":"The first listed value ends in _UNSPECIFIED or _UNKNOWN.","why":"The guide says the first value is a zero value with one of those suffixes, used as an unknown or default value."},{"id":"c","text":"Value names are written in TitleCase, like type names.","whyNot":"TitleCase is for enum type names; enum value names use UPPER_SNAKE_CASE."},{"id":"d","text":"Two sibling enums may both define SET, since each value is scoped to its enum.","whyNot":"Values are not scoped by their enum, so the same name in two sibling enums is not allowed."},{"id":"e","text":"Numbers may skip values to leave room for later additions.","whyNot":"The guide asks for numbers assigned densely and sequentially; gaps are for removed values."},{"id":"f","text":"Top-level enum values never need a prefix, since they are scoped.","whyNot":"Name collisions are a high risk for top-level enums, so the guide recommends one of its prefixing practices."}],"answer":"ab","explanation":"The style guide writes enum value names in UPPER_SNAKE_CASE and makes the first value a zero value ending in _UNSPECIFIED or _UNKNOWN.","concept":"The style guide writes enum value names in UPPER_SNAKE_CASE and makes the first value a zero value ending in _UNSPECIFIED or _UNKNOWN.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Enum values are UPPER_SNAKE_CASE, and the first value ends in _UNSPECIFIED."]},{"id":"grpcbeginner-005","courseId":"grpc-beginner","domain":"message-schema","topic":"Field naming style","prompt":"A message needs a repeated field that holds many Song messages. Which field declaration follows the protobuf style guide?","hint":"Look at the casing of the name and whether it is singular or plural.","explain":"Field names follow one fixed casing style, and a field that holds a collection of values gets a name in the matching form. Check both the casing and whether the name is singular or plural.","source":"https://protobuf.dev/programming-guides/style/","interaction":{"type":"single"},"options":[{"id":"a","text":"repeated Song songs = 2;","why":"Field names are snake_case, and a repeated field takes a plural name."},{"id":"b","text":"repeated Song song = 2;","whyNot":"A repeated field should take a plural name, so song is the wrong form."},{"id":"c","text":"repeated Song Tracks = 2;","whyNot":"Field names use snake_case, not TitleCase; TitleCase is for message names."},{"id":"d","text":"repeated Song songList = 2;","whyNot":"Field names use snake_case, not camelCase."}],"answer":"a","explanation":"Field names use snake_case, and repeated fields use plural names.","concept":"Field names use snake_case, and repeated fields use plural names.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Field names are snake_case; a repeated field gets a plural name."]}]