Array in Java - Quiz

  • A The code has compile errors because the variable arr cannot be changed once it is assigned.
  • B The code has runtime errors because the variable arr cannot be changed once it is assigned.
  • C The code can compile and run fine. The second line assigns a new array to arr.
  • D The code has compile errors because we cannot assign a different size array to arr.
  • A The program has a compile error because new int[2]
  • B The program has a runtime error because a[1]
  • C a[1] is 0
  • D a[1] is 1
  • A objects
  • B object references
  • C primitive data type
  • D None of the above
  • A Arrays can store only objects and not primitive types.
  • B Arrays have a fixed size.
  • C Arrays can be multidimensional.
  • D Elements of an array are accessed using an index.
  • A A copy of the array.
  • B A copy of the first element.
  • C The reference of the array.
  • D The length of the array.
  • A char[] c = new char();
  • B char[] c = new char[5];
  • C char[] c = new char(4);
  • D char[] c = new char[];