Study

Arrays in Java

  •   0%
  •  0     0     0

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