Weekly Quiz number: 14 (2026)

Solve the quiz and collect tokens!

Type your nickname in the field below before submitting your solution. If you select the correct answer and submit it with your nick-name a token will be generated for you. Collect tokens and the corresponding nickname(s). If you get at least 10 of them you might be rewarded ;-)


Coding Quiz: Object-Oriented Easter Eggs

Spring has sprung, and with it comes the annual tradition of hiding Easter eggs in the garden -- and hiding bugs in C++ code. Much like searching for chocolate eggs in tall grass, debugging C++ can leave you questioning your life choices. This quiz explores some of the more... unfortunate object-oriented aspects of C++ (up to C++17), wrapped in a festive layer of Easter-themed code. No new, no std::vector, no safety net. Just you, the compiler, and the nagging feeling that something is about to go terribly wrong.

Question 1: 'Tis But A Slice

Consider the following code, in which a GoldenEgg is placed into an Easter basket:

struct EasterEgg {
    virtual const char* color() const { return "plain white"; }
};
struct GoldenEgg : EasterEgg {
    const char* color() const override { return "glorious gold"; }
};
void placeInBasket(EasterEgg egg) {
    // What does egg.color() return here?
}
int main() {
    GoldenEgg precious;
    placeInBasket(precious);
    return 0;
}

What does egg.color() return inside placeInBasket?

A. "glorious gold" -- it is a GoldenEgg after all
B. "plain white" -- the egg has been mercilessly sliced
C. Undefined behaviour -- virtual calls on sliced objects are cursed
D. Compilation error -- you cannot pass a derived object by value

Question 2: Nobody Expects the Implicit Conversion

The Easter Bunny has written a function to hide eggs in the garden. Observe:

struct Egg {
    int weight_grams;
    Egg(int w) : weight_grams(w) {}
};
void hideInGarden(const Egg& egg) {
    // diligently hides the egg
}
int main() {
    hideInGarden(42);
    return 0;
}

What happens when this code is compiled?

A. Compilation error -- 42 is not an Egg, it is a number, you absolute walnut
B. Compiles without complaint -- 42 is silently converted into an Egg weighing 42 grams
C. Undefined behaviour -- binding a temporary to a const reference is forbidden by the Standard

Question 3: The Deadly Diamond of Easter

The chocolate factory has gotten creative and produced a hybrid confection:

struct ChocolateAnimal {
    int cocoa_percent = 50;
};
struct Bunny : ChocolateAnimal {
    bool has_ears = true;
};
struct Egg : ChocolateAnimal {
    bool is_hollow = true;
};
struct BunnyEgg : Bunny, Egg {
    // A bunny-shaped egg. Or an egg-shaped bunny.
    // Either way, a crime against confectionery.
};
int main() {
    BunnyEgg abomination;
    int c = abomination.cocoa_percent;
    return 0;
}

What happens?

A. Returns 50 -- there is only one cocoa_percent, obviously
B. Returns 100 -- both bases contribute their chocolate, it is twice as delicious
C. Compilation error -- ambiguous access to cocoa_percent
D. Undefined behaviour -- the Standard does not cover confectionery abominations

Question 4: The Ministry of Silly Declarations

Roger the Easter Bunny is being constructed for duty:

struct Bunny {
    int carrots_eaten;
    Bunny() : carrots_eaten(0) {}
    explicit Bunny(int c) : carrots_eaten(c) {}
    int report() const { return carrots_eaten; }
};
int main() {
    Bunny roger();
    return roger.report();
}

What happens?

A. Compiles and returns 0 -- Roger has eaten no carrots yet
B. Compiles and returns a random value -- carrots_eaten is uninitialised
C. Compilation error -- roger is not a Bunny, it is a function declaration
D. Compiles but crashes at runtime due to calling a method on a function pointer

Software Design Meeting

The coaching team holds a software design meeting every Thursday. It is open to anyone looking to expand their knowledge and connect with like-minded peers. (To receive an invitation, please reach out to Milosz Walter (XC-AS/EDE4))

E-Mail Reminder

Want a quick email notification in your inbox when the next quiz is live? Visit https://bos.ch/coding-quiz-reminder


Make sure your nickname contains at least 8 characters and is a unique as possible.




Disclaimer: