Array in Java - Quiz

  • Aobjects
  • Bobject references
  • Cprimitive data type
  • DNone of the above
  • Achar[] c = new char();
  • Bchar[] c = new char[5];
  • Cchar[] c = new char(4);
  • D char[] c = new char[];
  • BCompilation error, arrays cannot be initialized to zero size.
  • CCompilation error, it is a.length() not a.length
  • DNone of the above
  • Aint [] myList = {};
  • Bint [] myList = (5, 8, 2);
  • Cint myList [] [] = {4,9,7,0};
  • Dint myList [] = {4, 3, 7};
  • 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.