subject

Assuming that s and t are Strings, which of the following code fragments are such that the value returned by s. indexOf( t ) before the code is executed is equal to the value of the int n after the code is executed? I. int n = -1;
int tSize = t. length();
boolean found = false;
while ( !found && tSize <= s. length() )
{
n++;
if ( t. equals( s. substring( 0, tSize ) ) )
found = true;
else
s = s. substring( 1 );
}
if ( !found )
n = -1;
II. int n = -1;
int sSize = s. length();
int tSize = t. length();
boolean found = false;
while ( !found && n + tSize + 1 <= sSize )
{
n++;
if ( t. equals( s. substring( n, n + tSize ) ) )
found = true;
}
if ( !found )
n = -1;
III. int n = 0;
int sSize = s. length();
int tSize = t. length();
boolean found = false;
while ( !found && n + tSize <= sSize )
{
if ( t. equals( s. substring( n, n + tSize ) ) )
found = true;
n++;
}
if ( found )
n--;
else
n = -1;
A. I only
B. II only
C. III only
D. I and II only
E. I, II, and III

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
To increase sales, robert sends out a newsletter to his customers each month, letting them know about new products and ways in which to use them. in order to protect his customers' privacy, he uses this field when addressing his e-mail. attach bcc forward to
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Which of the following is not a way in which trees benefit the environment? a. they remove a significant amount of carbon dioxide from the atmosphere. b. they remove a significant amount of oxygen from the atmosphere. c. their roots hold soil in place, reducing rates of erosion. d. they remove ozone and particulates from the atmosphere. select the best answer from the choices provided a b c d
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 3
question
Computers and Technology, 24.06.2019 15:00
Universal windows platform is designed for which windows 10 version?
Answers: 1
You know the right answer?
Assuming that s and t are Strings, which of the following code fragments are such that the value ret...
Questions
question
Mathematics, 23.01.2021 14:40
question
World Languages, 23.01.2021 14:40
question
World Languages, 23.01.2021 14:40
question
Arts, 23.01.2021 14:40
question
Mathematics, 23.01.2021 14:40
question
Mathematics, 23.01.2021 14:50
Questions on the website: 13722363