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
The information provided in text aids can help us to understand a text’s content before we even read it.
dimaraw [331]
It is true that the information provided in text aids can help us to understand a text's content before we even read it.
These text aids will contain bits and pieces from the text, which will make us understand the overall message even before we actually get down to going through the text itself. I believe it is better to actually read the text, and try to understand it on your own, before going to these aids for help.
7 0
3 years ago
Which of the following is not an advantage of concurrent design?
viva [34]

The answer I believe is B

7 0
3 years ago
Read 2 more answers
Which of these is not considered a final step when creating a Podcast? Getting a loan to help with the cost of the equipment. Ch
Neporo4naja [7]

Answer:

Option 1

Explanation:

Ok first off if your taking out a loan for your podcasting thats a issue. The other options are what you would normally do when setting it up because chances are you have the equipment necessary to start the podcast.

Hope this helps:)

6 0
3 years ago
How do I send the face to the back? Seriously, I can't find out how...
makvit [3.9K]

Answer:

i think you can layer it :)

Explanation:

nice drawing btw!

8 0
3 years ago
(Game Design) Creating and manipulating data structures is one of the primary functions of a development environment.
Galina-37 [17]

true i believe im not for sure

7 0
3 years ago
Read 2 more answers
Other questions:
  • 10. Which of these is not an HTTP verb? PUT AJAX GET DELETE
    12·1 answer
  • Buildings must be wired to comply with the latest National Electrical Code to ensure that, with adequate maintenance, the instal
    11·1 answer
  • A technician is troubleshooting a computer that will not communicate with any hosts on the local network. While performing a vis
    9·1 answer
  • Paragraph on how atms work
    15·1 answer
  • When a Firewall is a hardware interface, it is referred as a
    6·1 answer
  • Plz help ASAP
    10·1 answer
  • What is the advantage of maintaining a list of keywords while creating a design blueprint?
    13·2 answers
  • With which type of test question should you leave yourself extra time to answer?
    14·2 answers
  • Copying materials from a source text without using is<br> considered plagiarism<br> ?
    5·1 answer
  • What is your impression on the subject fundamentals of database systems?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!