Computers and Technology

Consider the following method, which is intended to count the number of times the letter "A" appears in the string str. public static int countA(String str)
{
int count = 0;
while (str. length() > 0)
{
int pos = str. indexOf("A");
if (pos >= 0)
{
count++;
/* missing code */
}
else
{
return count;
}
}
return count;
}

Which of the following should be used to replace /* missing code */ so that method countA will work as intended?

A) str = str. substring(0, pos);
B) str = str. substring(0, pos + 1);
C) str = str. substring(pos - 1);
D) str = str. substring(pos);
E) str = str. substring(pos + 1);

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:00, jgrable5175
Designing a mobile web page is a little different from designing a regular web page. name at least three features that should be considered when designing a website that is mobile phone-friendly, and briefly explain why they are important.
Answers: 1
image
Computers and Technology, 22.06.2019 10:50, whocares1234
A911 dispatcher is the sole sender of messages to all police officers. while on patrol, officers communicate with the dispatcher who, in turn, relays messages to other officers. the officers do not communicate directly with one another. this illustrates a network.
Answers: 1
image
Computers and Technology, 22.06.2019 22:00, delawdermia27
Researchers measured the data speeds for a particular smartphone carrier at 50 airports. the highest speed measured was 78.1 mbps. the complete list of 50 data speeds has a mean of x overbarequals16.11 mbps and a standard deviation of sequals18.65 mbps. a. what is the difference between carrier's highest data speed and the mean of all 50 data speeds? b. how many standard deviations is that [the difference found in part (a)]? c. convert the carrier's highest data speed to a z score. d. if we consider data speeds that convert to z scores between minus2 and 2 to be neither significantly low nor significantly high, is the carrier's highest data speed significant? a. the difference is nothing mbps.
Answers: 3
image
Computers and Technology, 22.06.2019 23:30, Arealbot
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 1
Do you know the correct answer?
Consider the following method, which is intended to count the number of times the letter "A" appears...

Questions in other subjects:

Konu
Mathematics, 09.04.2021 03:50