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 18:30
What is outfitting a workplace with video in a technology
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
What is the term for water wave that is created by an underwater earthquake
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Quick pl which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
You know the right answer?
Use the arr field and mystery () method below. private int[] arr;

//precondition: arr....
Questions
question
Mathematics, 11.11.2019 10:31
question
Computers and Technology, 11.11.2019 10:31
question
Biology, 11.11.2019 10:31
Questions on the website: 13722360