subject

Use the arr field and mystery () method below. private int[] arr;

//precondition: arr. length > 0
public void mystery()
{
int s1 = 0;
int s2 = 0;

for (int i = 0; i < arr. length; i++)
{
int num = arr[i];

if ((num > 0) && (num % 2 == 0))
{
s1 += num;
}
else if (num < 0)
{
s2 += num;
}
}

System. out. println(s1);
System. out. println(s2);
}
Which of the following best describes the value of s1 output by the method mystery?

The sum of all values greater than 2 in arr
The sum of all values less than 2 in arr
The sum of all positive values in arr
The sum of all positive odd values in arr
The sum of all positive even values in arr

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 14:30
Which of the following would not be considered a pc? a. mainframe b. desktop c. tablet pc d. laptop
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
question
Computers and Technology, 24.06.2019 08:00
How can smart devices benefit businesses, organizations, and social communities in the global marketplace?
Answers: 1
You know the right answer?
Use the arr field and mystery () method below. private int[] arr;

//precondition: arr....
Questions
question
Geography, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
question
Biology, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
question
Mathematics, 23.01.2021 04:00
Questions on the website: 13722360