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 08:30
Active listen eliminates barries to communication true or false
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
The "instance" relationship shows that something is an object of a
Answers: 1
question
Computers and Technology, 22.06.2019 19:40
Solve the following javafx application: write a javafx application that analyzes a word. the user would type the word in a text field, and the application provides three buttons for the following: - one button, when clicked, displays the length of the word.- another button, when clicked, displays the number of vowels in the word.- another button, when clicked, displays the number of uppercase letters in the word(use the gridpane or hbox and vbox to organize the gui controls).
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
Write pseudocode to represent the logic of a program that allows the user to enter a value. the program multiplies the value by 10 and outputs the result.
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, 21.01.2021 21:00
question
History, 21.01.2021 21:00
question
Mathematics, 21.01.2021 21:00
question
Mathematics, 21.01.2021 21:00
Questions on the website: 13722361