The use of the key word instanceof is an extremely bad practice and should almost never be used in common application code (an exception is the method Object#equals()). It is a bad practice because it breaks object orientation and promotes the use of tedious if .. else or switch constructs. My son has solved the task by using instanceof. Now I wonder whether this was the intended solution. As I can not repeat the task in order to check this, I am asking you.