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, 22.06.2019 21:30
Nathan wants to create multiple worksheet containing common formatting styles for his team members. which file extension him to save these worksheets? nathan to create multiple worksheets with common styles. he needs to save them with the extension.
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
question
Computers and Technology, 24.06.2019 00:40
What social factors affect your health
Answers: 3
You know the right answer?
Consider the following code segment. int[][] arr = {{3, 2, 1}, {4, 3, 5}};
for (int row = 0;...
Questions
question
Biology, 11.06.2021 21:10
question
Mathematics, 11.06.2021 21:10
question
Mathematics, 11.06.2021 21:10
Questions on the website: 13722362