Game Preview

Arrays

  •  English    14     Public
    Manage large amounts of data or complex relationships in data using arrays. Traverse the elements of a 1D array by using iteration statements to access all elements of an array.
  •   Study   Slideshow
  • What is the index of the last element of the array values? int[ ] values = new int[10]
    9
  •  10
  • Write a Java statement to print the first element of the array values. int[ ] values = new int[10]
    System.out.print(values[0]);
  •  10
  • What is the final value of the variable counter after executing the following code segment?
    6
  •  10
  • What is the value that represents the length of the extra array that is declared in the following code segment?
    22
  •  10
  • What is the problem in the following code segment? double[] score = new int[99];
    Type mismatch
  •  10
  • What is the final output of the following code segment?
    ArrayIndexOutOfBoundsException
  •  10
  • Mention one disadvantage of using an enhanced for loop.
    Cannot assign a value to an element of an array.
  •  10
  • What output is generated by the following code segment?
    4
  •  10
  • What is the content of rooster array after executing the following code segment?
    7.3
  •  10
  • What is the output of the following code segment?
    3040
  •  10
  • What is the valid range of index values for an array of size 20?
    0 to 19
  •  10
  • What is the output of the given code segment?
    2345
  •  10
  • Which one of the following statements is correct for the given code segment?
    b) Line 2 causes a bounds error because 3 is an invalid index number.
  •  10
  • What will be the output of the following code segment?
    0
  •  10