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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:30, ibrahimuskalel
Avariable definition defines the name of a variable that will be used in a program, as well as
Answers: 3
image
Computers and Technology, 23.06.2019 01:20, shiann2002
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
image
Computers and Technology, 23.06.2019 06:00, ashleyd198308
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
image
Computers and Technology, 23.06.2019 08:30, sofigaviria05
All of these are true about using adhesive except: a. dissimilar materials can be joined. b. mixing tips are product and material specific. c. a specific application gun may be required. d. two-part adhesives are dispensed using two mixing tips
Answers: 3
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 in other subjects: