A. Object[] o = new String[1];Correct answer
Arrays are covariant: because String is a subtype of Object, String[] is a subtype of Object[], so the reference widens and this compiles (JLS 8 §4.10.3). Java defers the risk to run time — storing a non-String through the Object[] view raises ArrayStoreException.
B. List<Object> l = new ArrayList<String>();
Applies array covariance to generics, which are invariant (JLS 8 §4.5): the String/Object relationship creates no relationship between List<String> and List<Object>, so javac reports `incompatible types: ArrayList<String> cannot be converted to List<Object>`. A wildcard such as List<? extends Object> would be needed for the widening.
C. String[] s = new Object[1];
Assumes array covariance also narrows. It only widens (String[] to Object[]), never the reverse — an Object[] may hold anything, so exposing it as a String[] would be unsound. javac reports `incompatible types: Object[] cannot be converted to String[]`; an explicit cast would then fail at run time.
D. List<String> l = new ArrayList<Object>();
Invariance pointed the other way, for someone who concluded the generic rule was directional. With generics NEITHER direction is implicit: javac reports `incompatible types: ArrayList<Object> cannot be converted to List<String>`.
Explanation
Arrays are COVARIANT and generics are INVARIANT. That single asymmetry decides all four statements, and it is the contrast the exam keeps coming back to.
`Object[] o = new String[1];` compiles: because `String` is a subtype of `Object`, `String[]` is a subtype of `Object[]`, so the array reference widens. Java pays for this at run time instead -- store a non-String into that array through the `Object[]` view and you get an `ArrayStoreException`. The compiler lets it through; the JVM catches it.
Why the others are wrong:
`List<Object> l = new ArrayList<String>();` is the generic mirror of the statement that works, and it is exactly what invariance forbids. No relationship between `String` and `Object` creates any relationship between `List<String>` and `List<Object>`; they are unrelated types, full stop. javac says `incompatible types: ArrayList<String> cannot be converted to List<Object>`. Use `List<? extends Object>` if you want the widening.
`String[] s = new Object[1];` assumes covariance runs downward too. It does not. Covariance widens (`String[]` to `Object[]`), never narrows -- an `Object[]` may hold anything, so handing it out as a `String[]` would be unsound. This one needs an explicit cast, and the cast would then fail at run time. javac: `incompatible types: Object[] cannot be converted to String[]`.
`List<String> l = new ArrayList<Object>();` is invariance again, pointed the other way, for the student who concluded the rule was directional. It is not: with generics NEITHER direction is implicit.
Exam tip: the fastest way through a question like this is to ask, per line, "array or generic?" Arrays widen and blow up later; generics refuse to widen at all. And remember the reason the language is inconsistent here -- arrays predate generics, and their covariance is a hole that erasure could not afford to repeat.