Because Java is a statically typed language, the compiler goes by the declared type (that is, the variable type) of the reference because, in most real-world cases, the runtime type (the one he is apparent in the new expression) is not necessarily known at compile time.