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
What device is designed specifically to reduce broadcast traffic that passes over a network and to choose the best path for movi
mezya [45]

Answer:

Router        

Explanation:

  • A router is a network device that forwards data packets between networks. Its a network layer hardware device. For example a DSL router that connects to the Internet through an internet service provider.
  • Router is connects at least 2 networks (can be two LANs) and the ISP.
  • Router is used to transfer data from one network to another if both networks use same protocols.
  • It receives data in packets form and forwards the data to another router using a routing table. These data packets can be sent between devices or from devices to the internet.
  • The routing table is used to choose the optimal path for forwarding the packets between the source and destination hosts. Routing table configure the best route a packet can take to reach its destination using routing protocols. A Routing Protocol defines how routers connect with each other and share information that makes them choose routes on a computer network between source and destination. Routing tables can be configured statically (routes are fed manually) or dynamically (routes are updated based on information obtained  from other routers).
  • Router makes sure that the data packets reach right destination instead of being lost within the network and it also strengthen signals before transmitting them.
  • Routers reduce broadcast traffic. They form boundaries between broadcast domains and separate a network into multiple broadcast domains.
  • Router do not broadcast traffic and eliminates the packet when it detects a broadcast address. Routers also stop broadcast messages and don't route a broadcast message between broadcast domains.
6 0
3 years ago
Which is the last step to creating a community garden
pentagon [3]

Answer:

construct the garden

Explanation:

step 1. survey the property

step 2. test the soil

step 3. clean contaminants

step 4. consider garden design

step 5. construct the garden

7 0
3 years ago
Talia was a scientist whose research compared the birth rates of young women of a New England community over the course of five
podryga [215]

Answer: b

Explanation: for me personally i will populate an infographic(chart)rather than essay form i prefer to use an infographic to show my anaylis how it went high or low or when.

8 0
3 years ago
Read 2 more answers
Why do people in jonas's community have the same birthday?
alexira [117]
Everyone was not born in the same day but they do not celebrate birthdays like us.  Every year they move the class of children who were born in the same year up together.  This means that all of the babies who are recognized as Ones will be recognized as Twos together, and then Threes in another year.

Since the babies are not all the same age biologically, some kids have an advantage. 

Some were already walking, wobbly on their unsteady legs; others were no more than a few days old, wrapped in blankets, held by their Nurturers. (ch 2, p. 11)

Although it is claimed that the differences disappear by the time they are school age, there might be some advantage to being an older One versus a younger One.  Jonas was a little bit older, and he notes that it had given him a “slight advantage” when he was younger (ch 7, p. 50).  Since he is more sensitive and mature than the others, perhaps the advantage was not slight or temporary.

There are fifty children born each year.  They are given numbers from 1 to 50.  Their parents refer to them by number and not by name whenever they are frustrated with them, kind of like how our parents call their children by their full names.

Sometimes parents used them in irritation at a child's misbehavior, indicating that mischief made one unworthy of a name. (ch 7, p. 50)

For this reason, kids may not like hearing their numbers.  However, having a number is just part of their lives.  Since they are taught from a young age to not value individuality, it would not concern them to have a number.

The use of numbers and the abandonment of birthdays were both attempts by the community to institute Sameness.  This way, no one is singled out.  No one person is celebrated, except when the Ceremony of Twelve gives them assignments.  Everyone works for the good of the community, and the self is unimportant.

i read this book a lot so I mentioned the pg

3 0
3 years ago
_____ is a web application server that provides the ability to connect web servers to multiple data sources.
o-na [289]
ColdFusion/JRun is a web application server that provides the ability to connect web servers to multiple data sources.ColdFusion/JRun  is an application server developed by Adobe, that is based on Sun Microsystems' Java 2 Platform, Enterprise Edition (J2EE). The other options are eliminated because: Ms Access is <span>Database Management System , FoxPro is database development system and dBase is also data management system.</span>
7 0
4 years ago
Other questions:
  • Carlos owns a hardware store. He currently is not using any software to track what he has in the store. In one to two sentences,
    9·2 answers
  • , = , ?<br><br>) ..(++ &lt;= );<br><br>) ..(++ &lt;= );​
    10·1 answer
  • List and describe two of the four generally recognized security positions.
    6·1 answer
  • Which option of the Auto Correct tool enables you to add and delete words that do not follow abbreviation rules?
    11·2 answers
  • Why is outfitting a workplace with video games in a technology development company consiered a strategic use of money
    14·1 answer
  • Two technicians are discussing engine valve timing. Technician A says that the optimum valve timing is found through experimenta
    13·2 answers
  • If you play video games, please answer these questions it’s for a survey for my game development class!!
    5·1 answer
  • Write a line of code that declares a variable called shipName and set it equal to the string SpaceX3000.
    9·1 answer
  • A hardware component that keeps data and information when the device is not powered is called a ____ device.
    11·1 answer
  • Which of the following is an example of effective nonverbal communication?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!