Array in Java - Quiz

  • BCompilation error, arrays cannot be initialized to zero size.
  • CCompilation error, it is a.length() not a.length
  • DNone of the above
  • AThe program has a compile error because the size of the array wasn't specified when declaring the array.
  • BThe program has a runtime error because the array elements are not initialized.
  • C The program runs fine and displays x[0] is 0.
  • DThe program has a runtime error because the array element x[0] is not defined.
  • AThe code has compile errors because the variable arr cannot be changed once it is assigned.
  • BThe code has runtime errors because the variable arr cannot be changed once it is assigned.
  • CThe code can compile and run fine. The second line assigns a new array to arr.
  • DThe code has compile errors because we cannot assign a different size array to arr.
  • AA copy of the array.
  • BA copy of the first element.
  • CThe reference of the array.
  • DThe length of the array.
  • AThe program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by {1, 2, 3}.
  • BThe program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3};
  • CThe program has a compile error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0, 3.0};
  • D The program compiles and runs fine and the output
  • AArrays can store only objects and not primitive types.
  • BArrays have a fixed size.
  • CArrays can be multidimensional.
  • D Elements of an array are accessed using an index.