Unit 6 Arrays Quiz C#

20 Questions | Total Attempts: 884

SettingsSettingsSettings
Please wait...
Element Quizzes & Trivia

Questions and Answers
  • 1. 
    In an array, every element has the same .
    • A. 

      Subscript

    • B. 

      data type

    • C. 

      Memory location

    • D. 

      all of the above

  • 2. 
    Th e operator used to create objects is .
    • A. 

      =

    • B. 

      +=

    • C. 

      New

    • D. 

      Create

  • 3. 
    Which of the following correctly declares an array of four integers?
    • A. 

      Int array[4];

    • B. 

      Int[] array = 4;

    • C. 

      Int[4] array;

    • D. 

      Int[] array = new int[4];

  • 4. 
    Th e value placed within square brackets after an array name is .
    • A. 

      A subscript

    • B. 

      An index

    • C. 

      Always an integer

    • D. 

      all of these

  • 5. 
    If you defi ne an array to contain seven elements, then the highest array subscript you can use is .
    • A. 

      5

    • B. 

      6

    • C. 

      7

    • D. 

      8

  • 6. 
    Initializing an array is in C#.
    • A. 

      Required

    • B. 

      Optional

    • C. 

      Difficult

    • D. 

      Prohibited

  • 7. 
    When you declare an array of six double elements but provide no initialization values, the value of the fi rst 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}, as in Question 8, then the value of ages[1] is .
    • A. 

      0

    • B. 

      20

    • C. 

      30

    • D. 

      Out of bounce

  • 10. 
    When an ages array is correctly initialized using the values {20, 30, 40, 50}, as in Question 8, then the value of ages[4] is .
    • A. 

      0

    • B. 

      4

    • C. 

      50

    • D. 

      Out of Balance

  • 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 ten-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 > 15; ++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 .
    • A. 

      Analogous arrays

    • B. 

      Polymorphic arrays

    • C. 

      Relative arrays

    • D. 

      Parallel arrays

  • 15. 
    Assume an array is defi ned 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) Console.Write(nums[x]);

    • B. 

      For(int x = 3; x >= 0; --x) Console.Write(nums[x]);

    • C. 

      For(int x = 3; x > 0; --x) Console.Write(nums[x]);

    • D. 

      for(int x = 4; x >= 0; --x) Console.Write(nums[x]);

  • 16. 
    Assume an array is defi ned as int[] nums = {7, 15, 23, 5};. Which of the following would place the values in the array in descending numeric order?
    • A. 

      Array.Sort(nums);

    • B. 

      Array.Reverse(nums);

    • C. 

      Array.Sort(nums); Array.Reverse(nums);

    • D. 

      Array.Reverse(nums); Array.Sort(nums);

  • 17. 
    Which of the following traits do the BinarySearch() and Sort() methods have in common?
    • A. 

      Both methods take a single argument that must be an array

    • B. 

      Both methods belong to the System.Array class.

    • C. 

      Th e array that each method uses must be in ascending order.

    • D. 

      They both operate on arrays made up of simple data types but not class objects.

  • 18. 
    If you use the BinarySearch() method and the object you seek is not found in the array, .
    • A. 

      An error message is displayed

    • B. 

      A zero is returned

    • C. 

      The value false is returned

    • D. 

      A negative value is returned

  • 19. 
    Which of the following declares an integer array that contains eight rows and fi ve columns?
    • A. 

      Int[8, 5] num = new int[ , ];

    • B. 

      Int [8][5] num = new int[];

    • C. 

      Int [ , ] num = new int[5, 8];

    • D. 

      int [ , ] num = new int[8, 5];

  • 20. 
    Th e BinarySearch() method is inadequate when .
    • A. 

      array items are in ascending order

    • B. 

      The array holds duplicate values and you want to find them all

    • C. 

      You want to fi nd an exact match for a value

    • D. 

      Array items are not numeric

Back to Top Back to top