Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

16. What is stored in alpha after the following code executes? int[] alpha = new

ID: 3762084 • Letter: 1

Question

16.

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.

c.

b.

d.

17.

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.

b.

c.

d.

18.


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.

c.

b.

d.

19.

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.

b.

c.

d.

20.

Which method would you most likely use to add an element to an end of a vector?

a.

c.

b.

d.

16.

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}    

c.

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

b.

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

d.

alpha = {0, 2, 9, 6, 8} ABCD

17.

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. ABCD

18.

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);

c.

mystery(alpha, 40);    

b.

mystery(alpha[], 50);

d.

mystery(int[75], alpha) ABCD

19.

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]; ABCD

20.

Which method would you most likely use to add an element to an end of a vector?

a.

insertElementAt

c.

copyInto

b.

addElement

d.

lastElement

Explanation / Answer

16.
3 2 9 6 8

17.
This method returns the number of times item is stored in list. As count increases after item is found in the list

18.
c. mystery(alpha,40);
others have int[], which is not valid

19.
int sum = 0;
for(int j = 0; j < 7; j++)
sum = sum + sales[4][j];
4 is the index of 5th row

20.
addElement

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote