Game Preview

Arrays in Java

  •  English    16     Public
    Manage large amounts of data or complex relationships in data using arrays.
  •   Study   Slideshow
  • What is the term that refers to a collection of related elements used to store the same type of data called?
    Array
  •  10
  • Given the following declaration, what are the legal index values for the array ar?
    0, 1, 2, 3
  •  10
  • What does the following code segment print out?
    4
  •  10
  • What does the following code segment print out?
    2
  •  10
  • What does the following code segment print out?
    6
  •  10
  • What is the correct way to declare and initialize an integer array called numbers with 10 elements?
    int [ ] numbers = new int[10];
  •  10
  • What value is stored in each of the 5 elements in the following array?
    0
  •  20
  • What value is stored at index 1 in this array?
    Dennis
  •  10
  • What is the correct way to create an array called nums with the following three numbers? 12 8 15
    int[ ] nums = {12, 8, 15};
  •  10
  • True or False: An array can be used to store different types of data; such as: doubles and integers together.
    False
  •  10
  • How would you access the fourth element in array nums?
    nums[3]
  •  10
  • What is the correct way to create an array of 12 strings called months?
    String[ ] months = new String[12];
  •  10
  • What is the correct statement that gives the length of the array data?
    data.length
  •  10
  • Each element in a String array is automatically initialized to ___________.
    null
  •  20
  • True of False: An array has a fixed length.
    True
  •  10
  • Index values of an array range from ___________ to ___________.
    0 to length – 1
  •  20