1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
artcher [175]
3 years ago
12

The following method public String removeFromString(String old, String frag) removes all occurences of the string frag from the

string old. For example, removeFromString("hello there!", "he") returns "llo tre!" removeFromString("lalalala", "l") returns "aaaa" Which of the following blocks of code will successfully implement removeFromString()?
Computers and Technology
1 answer:
Mashutka [201]3 years ago
4 0

private static String removeFromString(String old, String frag)

{

int i = old.indexOf(frag);

while (i> -1) {

String rest = old.substring(i + frag.length());

System.out.println("rest = " + rest);

old = old.substring(0, i);

System.out.println("rest = " + old);

old = old + rest;

System.out.println("rest = " + old);

i = old.indexOf(frag);

System.out.println("i = "+ i);

}

return old;

}

Here the index of first occurrence is obtained outside the “while loop” and if this loop runs until index value is >-1. It extracts the rest of the characters other than “frag” from the index and all the characters for which the given set of characters are removed.

You might be interested in
Malware is any malicious software installed on a computer or network without the owner’s knowledge.
Naya [18.7K]

Answer: True

Explanation: Malware is literally short for malicious software. The name that is given to any type of software that could harm a computer system or collect a user's data.

Hope it helped please mark as brainliest!

8 0
3 years ago
Which is the value that expressions within conditional statements return?
Norma-Jean [14]

Answer:

i think its B Int

Explanation:

i hope i helped you figure it out if not sorry i will try harder next time :3

5 0
3 years ago
consider l= 5 ,r= 11. you must determine the sum of the values of the function in the range L to R . you have to calculate sum =
4vir4ik [10]

def summation (num1, num2):

i = 0

for x in range (num1 : num2 + 1):

i += x

return i

print ( summation(l, r))

3 0
3 years ago
Is a pocket watch consider a computer
gulaghasi [49]

Answer:

I don't think a pocket watch is considered a computer based off of my logic. Other people may think differently tho.

Explanation:

7 0
3 years ago
The condition, ____, entered in the criteria row of a long text field in a query window would retrieve all records where the lon
skad [1K]
A query criterion<span> is an expression that Access compares to query field values to determine whether to include the record that contains each value</span><span>
The condition, *education, entered in the criteria row of a long text field in a query window would retrieve all records where the long text field had any mention of education.</span>
6 0
3 years ago
Other questions:
  • When creating a software package, the software must be designed, the code must be written, and then the code must be tested. Thi
    6·1 answer
  • In object-oriented analysis, objects possess characteristics called _____.â
    14·1 answer
  • What was the second phone made in the world called?
    5·1 answer
  • A computer program uses 3 bits to represent integers. When the program adds the decimal (base 10) numbers 6 and 2, the result is
    13·1 answer
  • What actions are considered positive body language?
    12·1 answer
  • Inthe old days, databases did NOT support ____________.
    10·1 answer
  • Which is a reason why an organization might get rid of its entire information processing unit?
    10·1 answer
  • Can someone answer this ?
    7·1 answer
  • How is hybrid computer used in hospitals? please reply fast!!​
    14·1 answer
  • What method does a gsm network use to separate data on a channel?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!