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
Of the measures of feasibility, questions such as "Does the proposed platform have sufficient capacity for future needs?" and "W
larisa [96]
Operational feasibility !!!!!!!
8 0
4 years ago
How to remove a channel from favorite list on suddenlink?
Thepotemich [5.8K]
Press delete channels
6 0
3 years ago
When using overloaded functions in appication code, the compiler will call which one
musickatia [10]

Answer:

The function with same name,same number and type of arguments.

Explanation:

Function overloading occurs when the functions with same name in the same scope with the same return type but different argument numbers and different argument types.So when we want to call a specific function we have to pass the same number of arguments with same type of arguments.We can do function overloading for the functions with same return type only.

7 0
4 years ago
Can someone please help with this thanks luvs c
aivan3 [116]

Answer:

HELLO, be nice spread love... DO NOT HATE ON OTHERS

░░░░░▐▀█▀▌░░░░▀█▄░░░

░░░░░▐█▄█▌░░░░░░▀█▄░░

░░░░░░▀▄▀░░░▄▄▄▄▄▀▀░░

░░░░▄▄▄██▀▀▀▀░░░░░░

░░░█▀▄▄▄█░▀▀░░

░░░▌░▄▄▄▐▌▀▀▀░░ This is Bob

▄░▐░░░▄▄░█░▀▀ ░░

▀█▌░░░▄░▀█▀░▀ ░░ Copy and paste him so he can take over brainly.

░░░░░░░▀███▀█░▄░░

░░░░░░▐▌▀▄▀▄▀▐▄░░

░░░░░░▐▀░░░░░░▐▌░░

░░░░░░█░░░░░░░░█░

COPY AND PASTE LETS DEFEAT BRAINLY

Explanation:

8 0
3 years ago
Which three steps might be included in an algorithm for a digital thermostat?
chubhunter [2.5K]

Answer:

Explanation:

It certainly isn't D. It would cost a fortune to make that happen. It's not impossibe. Just impractical.

It's not A. Resistance is a floating physical thing present in the air.

B could be correct, but there is a better answer.

The answer is C. A thermistor is a resistance that is temperature sensitive.

7 0
2 years ago
Other questions:
  • The mass of a textbook is about 1.25 kilograms. Aproximately, how many ounces is this?
    10·1 answer
  • WILL MARK BRAINLIEST IF ANSWERED ASAP
    10·1 answer
  • What is the term for the process of swapping items between memory and storage?
    5·2 answers
  • The following program contains 6 errors. Correct the errors and submit a working version of the program. The corrected version o
    13·1 answer
  • Write a javascript program that reads three integers named start, end, and divisor from three textfields. your program must outp
    6·2 answers
  • ___ consists of a central conductor surrounded by a shield (usually a wire braid).
    9·1 answer
  • How can you know if the person or organization providing the information has the credentials and knowledge to speak on this topi
    13·1 answer
  • What is stored in alpha after the following code executes?
    8·1 answer
  • Which of these tax forms reports an employee's yearly social security tax withheld
    11·2 answers
  • Question 3 of 25 In computer science, what is a developer? A. A person who organizes all the details of a project B. An individu
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!