Java Ch 7 - Arrays

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Tcarteronw
T
Tcarteronw
Community Contributor
Quizzes Created: 38 | Total Attempts: 29,972
Questions: 21 | Attempts: 2,186

SettingsSettingsSettings
Java Ch 7 - Arrays - Quiz

The computer window and operating system are essential to the functioning of a computer. Java Chapter 7 – Arrays may not be as simple or complex as you think so just try it out and see for yourself.


Questions and Answers
  • 1. 

         Which of the following declares an array of int named beta?

    • A.

      Int beta;

    • B.

      Int[] beta;

    • C.

      New int beta[];

    • D.

      Int beta = int[];

    Correct Answer
    B. Int[] beta;
    Explanation
    553

    Rate this question:

  • 2. 

    Int[] numList = new int[50];   for (int i = 0; i < 50; i++)     numList[i] = 2 * i;   num[10] = -20; num[30] = 8;   How many components are in the array numList seen in the accompanying figure?

    • A.

      0

    • B.

      30

    • C.

      49

    • D.

      50

    Correct Answer
    D. 50
    Explanation
    553-4

    Rate this question:

  • 3. 

    What is the index number of the last component in the array numList seen in the accompanying figure?

    • A.

      0

    • B.

      30

    • C.

      49

    • D.

      50

    Correct Answer
    C. 49
    Explanation
    556

    Rate this question:

  • 4. 

    Which of the following is the array subscripting operator in Java?

    • A.

      .

    • B.

      { }

    • C.

      New

    • D.

      [ ]

    Correct Answer
    D. [ ]
    Explanation
    555

    Rate this question:

  • 5. 

    Suppose you have the following declaration.   double[] salesData = new double[500];   Which of the following range is valid for the index of the array salesData. (i)  0 through 500 (ii) 0 through 499

    • A.

      Only (i)

    • B.

      Only (ii)

    • C.

      Both i and ii

    Correct Answer
    A. Only (i)
    Explanation
    556

    Rate this question:

  • 6. 

    What is the output of the following Java code?   int[] list = {0, 5, 10, 15, 20};   for (int j = 0; j < 5; j++)     System.out.print(list[j] + " "); System.out.println();

    • A.

      0 1 2 3 4

    • B.

      0 5 10 15 20

    • C.

      0, 5, 10, 15, 20

    • D.

      0 5 10 15

    Correct Answer
    B. 0 5 10 15 20
    Explanation
    559

    Rate this question:

  • 7. 

    What is the value of alpha[4] after the following code executes?   int[] alpha = new int[5];   for (int j = 0; j < 5; j++)     alpha[j] = 2 * j - 1;

    • A.

      One

    • B.

      Three

    • C.

      Five

    • D.

      Seven

    Correct Answer
    D. Seven
    Explanation
    559

    Rate this question:

  • 8. 

    What is stored in alpha after the following code executes?   int[] alpha = new int[5];   for (int j = 0; j < 5; j++) {    alpha[j] = 2 * j;      if (j % 2 == 1)       alpha[j - 1] = alpha[j] + j; }

    • A.

      Alpha = {0, 2, 4, 6, 8}

    • B.

      Alpha = {3, 2, 9, 6, 8}

    • C.

      Alpha = {0, 3, 4, 7, 8}

    • D.

      Alpha = {0, 2, 9, 6, 8}

    Correct Answer
    A. Alpha = {0, 2, 4, 6, 8}
    Explanation
    559

    Rate this question:

  • 9. 

    Int[] list = {1, 3, 5, 7}; for (int i = 0; i < list.length; i++)     if (list[i] > 5)         System.out.println(i + " " + list[i]);   Which indices are in bounds for the array list, given the declaration in the accompanying figure?

    • A.

      0, 1, 2, 3

    • B.

      1, 2, 3, 4

    • C.

      1, 3, 5, 7

    • D.

      0, 1, 3, 5

    Correct Answer
    A. 0, 1, 2, 3
    Explanation
    564

    Rate this question:

  • 10. 

    Consider the following method definition.   public static int strange(int[] list, int listSize, int item) {    int count = 0;      for (int j = 0; j < listSize; j++)       if (list[j] == item)          count++;      return count; } Which of the following statements best describe the behavior of this method?

    • A.

      This method returns the number of values stored in list.

    • B.

      This method returns the sum of all the values of list.

    • C.

      This method returns the number of times item is stored in list.

    • D.

      This method can process an array of doubles.

    Correct Answer
    C. This method returns the number of times item is stored in list.
    Explanation
    568-9

    Rate this question:

  • 11. 

    Given the following method heading   public static void mystery(int list[], int size)   and the declaration   int[] alpha = new int[75];   Which of the following is a valid call to the method mystery?

    • A.

      Mystery(alpha[75], 50);

    • B.

      Mystery(alpha[], 50);

    • C.

      Mystery(alpha, 40);

    • D.

      Mystery(int[75], alpha)

    Correct Answer
    C. Mystery(alpha, 40);
    Explanation
    570-1

    Rate this question:

  • 12. 

    How many objects are present after the code fragment in the accompanying figure is executed?

    • A.

      1

    • B.

      2

    • C.

      7

    • D.

      14

    Correct Answer
    A. 1
    Explanation
    565-6

    Rate this question:

  • 13. 

    Char[][] table = new char[10][5];    How many dimensions are in the array seen in the accompanying figure?

    • A.

      1

    • B.

      2

    • C.

      5

    • D.

      10

    Correct Answer
    B. 2
    Explanation
    590-1

    Rate this question:

  • 14. 

    Char[][] table = new char[10][5]; How many rows are in the array seen in the accompanying figure?

    • A.

      0

    • B.

      5

    • C.

      10

    • D.

      15

    Correct Answer
    C. 10
    Explanation
    590-1

    Rate this question:

  • 15. 

    Char[][] table = new char[10][5]; What is the value of table.length?

    • A.

      0

    • B.

      5

    • C.

      10

    • D.

      15

    Correct Answer
    C. 10
    Explanation
    592-3

    Rate this question:

  • 16. 

    Suppose that sales is a two-dimensional array of 10 rows and 7 columns wherein each component is of the type int. Which of the following correctly finds the sum of the elements of the fifth row of sales?

    • A.

      Int sum = 0; for(int j = 0; j < 7; j++) sum = sum + sales[5][j];

    • B.

      Int sum = 0; for(int j = 0; j < 7; j++) sum = sum + sales[4][j];

    • C.

      Int sum = 0; for(int j = 0; j < 10; j++) sum = sum + sales[5][j];

    • D.

      Int sum = 0; for(int j = 0; j < 10; j++) sum = sum + sales[4][j];

    Correct Answer
    B. Int sum = 0; for(int j = 0; j < 7; j++) sum = sum + sales[4][j];
    Explanation
    598

    Rate this question:

  • 17. 

    Arrays have a fixed number of elements.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    553

    Rate this question:

  • 18. 

    A single array can hold components of many different data types.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    553

    Rate this question:

  • 19. 

    The statement   int[] list = new int[15];   creates list to be an array of 14 components because array index starts at 0.

    • A.

      True

    • B.

      False

    Correct Answer
    B. False
    Explanation
    554

    Rate this question:

  • 20. 

    Given the declaration   double[] numList = new double[20];   the statement   numList[12] = numList[5] + numList[7];   updates the content of the thirteenth component of the array numList.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    556

    Rate this question:

  • 21. 

    You can create an array of reference variables to manipulate objects.

    • A.

      True

    • B.

      False

    Correct Answer
    A. True
    Explanation
    574-5

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 22, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Apr 09, 2014
    Quiz Created by
    Tcarteronw
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.