C# Unit 6

  1. In an array, every element has the same _______.

    A. subscript
    B. memory location
    C. data type
    D. all of the above
  2. The operator used to create objects is _______.

    A. =
    B. +=
    C. new
    D. create
  3. Which of the following correctly declares an array of six integers?

    A. int array[6];
    B. int[] array = 6;
    C. int[6] array;
    D. int[] array = new int[6];
  4. The value placed within square brackets after an array name is ______.

    A. always a constant
    B. always a double
    C. called a subscript
    D. all of these
  5. If you define an array to contain 10 elements, the the highest array subscript you can use is ______.

    A. 8 
    B. 9
    C. 10
    D. 11
  6. Initializing an array is _______ in C#.

    A. optional
    B. required 
    C. difficult
    D. prohibited
  7. When you declared an array of six double elements but provide no initialization values, the value of the first element is _______.

    A. 0.0
    B. 1.0
    C. 5.0
    D. unknown
  8. Which of the following correctly declares an array of four integers?

    A. int[] ages = new int[4] {20, 30, 40, 50};
    B. int[] ages = new int [] {20, 30, 40, 50};
    C. int[] ages = {20, 30, 40, 50};
    D. all of these
  9. When an ages array is correctly initialized using the values {20, 30, 40 50}, then the value of ages[1] is ______.

    A. 0
    B. 20
    C. 30
    D. undefined
  10. When an ages array is correctly initialized using the values {20, 30, 40 50}, then the value of ages[4] is ______.

    A. 0
    B. 4
    C. 50
    D. undefined
  11. When you declare an array as int[] temperature = {0, 32, 50, 90, 212, 451};, the value of temperature.Length is ______.

    A. 5
    B. 6
    C. 7
    D. unknown
  12. Which of the following doubles every value in a 10-element integer array named amount?

    A. for(int x = 9; x >= 0; --x) amount[x] *= 2;
    B. foreach(int number in amount) number *= 2;
    C. both of these
    D. neither of these
  13. Which of the following adds 10 to every value in a 16-element integer array named points?

    A. for(int sub = 0; sub > 16; ++sub) points[sub] += 10;
    B. foreach(int sub in points) points += 10;
    C. both of these
    D. neither of these
  14. Two arrays that store related information in corresponding element positions are _____ arrays.

    A. jagged
    B. parallel
    C. relative
    D. rectangular
  15. Assume an array is defined as int[] nums = {2, 3, 4, 5}; Which of the following would display the values in the array in reverse?

    A. for(int x = 4; x > 0; --x)
          Write(nums[x]);
    B. for(int x = 3; x > 0; --x)
          Write(nums[x]);
    C. for(int x = 3; x >= 0; --x)
          Write(nums[x]);
    D. for(int x =4; x >= 0; --x)
          Write(nums[x]);
    • C. for(int x = 3; x >= 0; --x)
    •       Write(nums[x]);
  16. Which of the following declares an integer array that contains eight rows and five columns?




    A. int [ , ] num = new int[8, 5];
  17. Assume an array is defined as int[] nums = {7, 15, 23, 5};. Which of the following would place the values in the array in descending numerical order?




    C. Array.Sort(nums); Array.Reverse(nums);
  18. If you use the BinarySearch() method, and the object you seek is not found in the array, ____________.




    A. a negative value is returned
  19. Which of the following traits do the BinarySearch() and Sort() methods have in common?




    B. Both methods belong to the System.Array class.
  20. The BinarySearch() Method is inadequate when _____________.




    C. the array holds duplicate values and you want to find them all
Author
jdavis123
ID
358240
Card Set
C# Unit 6
Description
Updated