Multiple choice java

Which one creates an instance of an array?

  1. int[ ] ia = new int[15];

  2. float fa = new float[20];

  3. char[ ] ca = "Some String";

  4. int ia[ ] [ ] = { 4, 5, 6 }, { 1,2,3 };

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Option A uses the correct syntax to declare and instantiate an array of integers with a size of 15. Option B attempts to assign an array to a single float variable. Option C attempts to assign a String literal to a char array (type mismatch). Option D has syntax errors in the array initialization expression.

AI explanation

int[] ia = new int[15]; correctly instantiates an array of 15 ints using the new type[size] syntax. float fa = new float[20]; is wrong because a float array reference can't be assigned to a scalar float variable — it needs float[] fa. char[] ca = "Some String"; fails because a String literal can't be assigned directly to a char array (that requires toCharArray()). int ia[][] = {4,5,6},{1,2,3}; has invalid initializer syntax — multi-dimensional array initializers need enclosing braces like {{4,5,6},{1,2,3}}. Only the first option is valid array instantiation.