It's because you use the instanceof operator in the equals() method, where the three object is seen as Object. As far as this method is concerned, the parameter could be ANY type of object and therefore it is possible that it gets a Moof.
The instanceof operator only generates a compile time error if the variable left of the "instanceof" and the type (class) right of the "instanceof" are not in the same type hierarchy. Since Object is the superclass of all classes, there is no error in your code.
In the outcommented line "i" is of type Integer and you try to check if it is of type String. This can never be true, because you can never assign a String object to variable i, because i is of type Integer. Remember that variables can never change their type.
The rest of the example I think is self explaining.