subject

Consider the following code segment. int[][] arr = {{3, 2, 1}, {4, 3, 5}};
for (int row = 0; row < arr. length; row++)
{
for (int col = 0; col < arr[row].length; col++)
{
if (col > 0)
{
if (arr[row][col] >= arr[row][col - 1])
{
System. out. println("Condition one");
}
}
if (arr[row][col] % 2 == 0)
{
System. out. println("Condition two");
}
}
}
As a result of executing the code segment, how many times are "Condition one" and "Condition two" printed?
A. "Condition one" is printed twice, and "Condition two" is printed twice.
B. "Condition one" is printed twice, and "Condition two" is printed once.
C. "Condition one" is printed once, and "Condition two" is printed twice.
D. "Condition one" is printed once, and "Condition two" is printed once.
E. "Condition one" is never printed, and "Condition two" is printed once.
2. Consider the following code segment.
int[][] arr = {{1, 3, 4}, {4, 5, 3}};
int max = arr[0][0];
for (int row = 0; row < arr. length; row++){
for (int col = 0; col < arr[row].length; col++)
{
int temp = arr[row][col];
if (temp % 2 == 0)
{
arr[row][col] = temp + 1; // line 11
}
if (temp > max)
{
max = temp;
}
}
}
System. out. println(max);
How many times will the statement in line 11 be executed as a result of executing the code segment?
A. 2
B. 3
C. 4
D. 5
E. 6
3. Consider the following method, sumRows, which is intended to traverse all the rows in the two-dimensional (2D) integer array num and print the sum of all the elements in each row.
public static void sumRows(int[][] num)
{
for (int[] r : num)
{
int sum = 0;
for (int j = 0; j < num. length; j++)
{
sum += r[j];
}
System. out. print(sum + " ");
}
}
For example, if num contains {{3, 5}, {6, 8}}, then sumRows(num) should print "8 14 ".
The method does not always work as intended. For which of the following two-dimensional array input values does sumRows NOT work as intended?
A. {{0, 1}, {2, 3}}
B. {{10, -18}, {48, 17}}
C. {{-5, 2, 0}, {4, 11, 0}}
D. {{4, 1, 7}, {-10, -11, -12}}
E. {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
Dereck works for long hours on his computer.  he frequently experiences physical strain by the end of the day because he does not follow an important rule of ergonomics with respect to the use of keyboards.  which of the following actions of dereck could lead to physical strain? a.  placing the keyboard exactly in front of him while typingb.  keeping hands and wrists straight while typingc.  using wrist pads throughout the dayd.  pounding at the keys on the keyboard while typinge.  resting his hands on the keyboard when he is not typing
Answers: 1
question
Computers and Technology, 25.06.2019 18:30
If you like to spend time outdoors working with plants and animals, you have a(n) a. bodily/kinesthetic learning style b. intrapersonal learning style c. visual/spatial learning style d. naturalistic learning style
Answers: 1
question
Computers and Technology, 26.06.2019 03:30
Aobject is used for displaying the results of a question based on stored data. a.query b. report c. table d. form
Answers: 1
You know the right answer?
Consider the following code segment. int[][] arr = {{3, 2, 1}, {4, 3, 5}};
for (int row = 0;...
Questions
question
Advanced Placement (AP), 03.01.2021 22:50
Questions on the website: 13722361