What happens when the Java code Object o = new String; o = 1; is run?
Correct answer C. An ArrayStoreException is thrown
Explanation
Arrays are covariant, so a String[] may be held in an Object[] variable, and storing an Integer type-checks at compile time. Each array remembers its real component type, however, and the JVM checks every store at run time. Putting an Integer into a String[] therefore raises ArrayStoreException, not the more familiar ClassCastException.
Answer checked How we write and check questions
Discussion