1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zvonat [6]
3 years ago
14

Consider the following method, which is intended to return the index of the first negative integer in a given array of integers.

public int positionOfFirstNegative(int[] values) { int index = 0; while (values[index] >= 0) { index++; } return index; } What precondition is needed on the values array so that the method will work as intended?
Computers and Technology
1 answer:
Aleksandr [31]3 years ago
3 0

Answer:

The answer is "The array values must contain at least one negative integer".

Explanation:

In the above-given code, a method "positionOfFirstNegative" is declared, that accepts an array "values" as a parameter, inside the method an integer variable index is declared, that use in the while loop to check array value is greater than equal to 0, if the conditional is true it will increments the index value and return its value, that's why in this question array value include at least one negative value.

You might be interested in
Dots (or periods) in a Java statement are used to separate the names of the components that make up the statement.
julia-pushkina [17]

Answer:

B) False

Explanation:

The java programming language uses Dots (periods) as an operator (The dot operator). It is used when referring to the variables or methods of a class. The syntax is ClassName.variableName or ClassName.methodName. We are very familiar with the System.out (java.lang.System.out) which refers to the variable out contained in the class System. Another example is input.nextInt( ) In this case the nextInt ( ) method is being called.

8 0
4 years ago
PLEASE ANSWER CORRECTLY
Bess [88]

Answer:

If you know how many passes you'll be making, a for loop is most suitable.

If you do not know ahead of time, the while loop is better, since the while condition will decide if you're going to make another round.

5 0
3 years ago
Which type of financial institution typically has membership requirements?
Anon25 [30]
Credit Union typically has membership requirements
8 0
3 years ago
A line of code that begins with the while needs to end which symbol?<br> # <br> "<br> :<br> .
olga_2 [115]
<h2>A line of code that begins with the "while" needs to end with <u>":"</u> symbol</h2>

Explanation:

In python, the while loop statement has ":" at the end of the line.

<u>Syntax:</u>

while expression:

code(s) or statement(s)

<u>Example:</u>

cnt = 0

while (cnt < 5):

  print 'cnt:', cnt

  cnt = cnt + 1

Like other programming languages, while loop works in the same way except that in python it comes alone with "else" statement. When the condition is false, "else" statement gets executed.

<u>Example:</u>

#!/usr/bin/python

cnt = 0

while cnt < 5:

  print cnt, " is  less than 5"

  cnt = cnt + 1

else:

  print cnt, " is not less than 5"

3 0
3 years ago
1. Write a program to input four numbers and store them in variables.
slega [8]
Honestly , brainly may seem like a place to get answers but it’s not , people come here to troll, like me
7 0
3 years ago
Other questions:
  • At the end of your presentation, the main points should be a. Summarized c. Handed to your teacher b. Written on the board d. Re
    7·2 answers
  • Which statement relating to a Works Cited page is NOT True?
    11·2 answers
  • The air in the atmosphere circulates mainly because _____.
    7·2 answers
  • What is the main piece of computer software on which every other piece of software relies?
    15·1 answer
  • function calculate () { var s = 2; var x = 2; var y = 3; if (x &gt; 4) { s=s+ 2; } else if ( y &gt; 4) { s=s+ 4; } else { s+=3;}
    11·1 answer
  • PLEASE HELP!!! History abounds with instances in which the work of scientists and artists were affected by the political, religi
    9·1 answer
  • What are the diffrent types of contract
    9·1 answer
  • Types of computer that we use in our daily life​
    13·2 answers
  • Yo need help can someone plz help
    7·1 answer
  • 37) Which of the following statements is true
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!