Welcome to the Ranch
It shows how important it is to read the questions carefully. The code TK showed you will compile, which is what matters for an exam question. It might be poor design, but the question isn't asking whether the code is well designed or not.
You have to be odd to be #1 - Seuss. An odd little ad: