subject

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);

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 13:30
Using the find and replace tool would be most appropriate when changing the company name when the same letter is sent to different companies. inserting a date field. suggesting alternate word choices with the same meaning. placing images alongside text.
Answers: 3
question
Computers and Technology, 22.06.2019 12:40
In a response of approximately 50 words, explain why it would be essential for the successful a/v technician to participate in additional coursework, presentations and seminars offered by equipment manufacturers as well as annual conferences attended by colleagues in the industry.
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Which of the following includes the three primary network access technologies? dsl, cable modem, broadband lan, wan, man voip, uc, iptv tcp/ip, ftp, dhcp
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Which best describes the condition under which the unicode output is the same as plain text ?
Answers: 1
You know the right answer?
Consider the following method, which is intended to count the number of times the letter "A" appears...
Questions
question
Mathematics, 19.03.2021 18:30
question
Biology, 19.03.2021 18:30
question
Chemistry, 19.03.2021 18:30
question
English, 19.03.2021 18:30
Questions on the website: 13722360