Computers and Technology

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

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 18:50, annieleblanc2004
Ais a picture icon that is a direct link to a file or folder
Answers: 1
image
Computers and Technology, 23.06.2019 22:20, kandi2565
What is a programming method that provides for interactive modules to a website?
Answers: 1
image
Computers and Technology, 24.06.2019 07:00, sudotoxic
Into what form does the barcode reader convert individual bar patterns?
Answers: 1
image
Computers and Technology, 24.06.2019 16:30, saadshami2384
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
Answers: 1
Do you know the correct answer?
Assuming that s and t are Strings, which of the following code fragments are such that the value ret...

Questions in other subjects: