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
Clive wants to write a query that will display the names of the students who scored less than 10 in their final exams. Which num
Mice21 [21]
I'd go for <span>FLOOR(x)
</span>

The numerical function FLOOR(x) can be used to return the largest integer value that is less than or equal to the numerical expression provided. The numerical function CEILING (x) is the opposite of FLOOR(x) since it gives the smallest integer value that is greater or equal to the numerical expression.






6 0
3 years ago
Read 2 more answers
It is not possible to use keywords to search for themes. true or false.
Drupady [299]
False my dude .........................
3 0
3 years ago
Question 6 options: This is a category or partitioned group of the small units of a programming language include its numeric lit
Wittaler [7]

Lexeme is a category or partitioned group of the small units of a programming language include its numeric literals, operators, and special words.

<h3>What is a lexeme in programming?</h3>

Lexemes are known to be those character strings that are put together from the character group of a program, and the token stands for what aspect of the program's grammar they are made of.

Hence, Lexeme is a category or partitioned group of the small units of a programming language include its numeric literals, operators, and special words.

Learn more about Lexeme from

brainly.com/question/14125370

#SPJ1

6 0
2 years ago
Why are using some special characters (@, #, !, etc.) not a good idea?
konstantin123 [22]
There are pros and cons to using special characters in email subject lines. Generally, marketers report higher open rates.

Some report better engagement, but many don’t.

There are also reports of special characters causing problems with deliverability, mostly because spammers became very fond of special characters for a while.
5 0
3 years ago
Read 2 more answers
Which of the following tags contains metadata about the webpage?
Andre45 [30]
I cannot see the options but I am guessing that it is just regular HTML

If that is the case the <meta></meta> tag can be used and should be placed within the <head></head> tag
8 0
3 years ago
Read 2 more answers
Other questions:
  • What is html?
    9·2 answers
  • . When you have multiple graphics positioned on a page, you can _______________ them so that they are a single graphic instead o
    9·1 answer
  • Which tabs are expandable and collapsible? Check all that apply.
    7·2 answers
  • What would happen to a eukaryotic cell if all its mitochondriawere destroyed
    7·1 answer
  • Ben's team is working on an English project. The members want to see everyone's progress on their part of the project. What tech
    7·2 answers
  • Lenovo's ThinkPad laptop computers is designed in the United States, the case, keyboard, and hard drive are made in Thailand; th
    14·1 answer
  • Issues with paper based records include a. time spent re-keying data, searching for paper copies, and filing. b. storage volume
    9·1 answer
  • A variable that can be modified from anywhere within a program is called a?
    5·1 answer
  • How to program a game​
    7·2 answers
  • the computer that communicate with each other are called ______please ask the answer in 15 minutes after 1 p.m. ​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!