x will refer to an Integer object because 12 is by default of type int and will be wrapped to an Integer object. At compile time the casting works fine since Long and Number in the same type tree but at run time it will fail and a classCastException will be thrown because java.lang.Integer cannot be cast to java.lang.Long.