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, 22.06.2019 13:00
Which option should u select to ignore all tracked changes in a document
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
Which of the following examples has four beats in each measure?
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
Sports and entertainment class, your goal is to increase attendance and make a profit for a game by getting your team on a winning track with total salaries less than $3,000,000
Answers: 3
question
Computers and Technology, 24.06.2019 14:30
In a home that has 120 v service, there is an electric appliance that has a resistance of 12 ohms. how much power will this appliance consume? a. 10 w b. 120 w c 1200 w d. 1440 w
Answers: 1
You know the right answer?
Use the arr field and mystery () method below. private int[] arr;

//precondition: arr....
Questions
question
Mathematics, 19.01.2021 22:30
question
Mathematics, 19.01.2021 22:30
question
Law, 19.01.2021 22:30