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 current in a resistor is 5.0 A, and its power is 60 W. What is the voltage?
alexandr1967 [171]

The voltage on a resistor will be "12 V".

According to the given question,

Current,

  • I = 5.0 A

Power,

  • P = 60

As we know the formula,

→ Power (P)= Current(I)\times Voltage (V)

or,

→              V = \frac{P}{I}

By putting the giving values, we get

→                  = \frac{60}{5}

→                  = 12 \ V

Thus the solution above is right.

Learn more about voltage here:

brainly.com/question/18883096

8 0
2 years ago
Read 2 more answers
While ________ is centered on creating procedures, ________ is centered on creating objects. Procedural programming, class progr
AlexFokin [52]

Answer

Procedural programming, Object-oriented programming

Explanation

Procedural programming is a type of computer programming language that specifies a series of well structured steps and procedures  within its development period of time. It contains a systematic order of statements, functions and commands to complete a computational task or program. It is centered on creating procedures. While object oriented programming is a programming language that is centered on creating objects rather that actions and data rather than logic.. It has four principles which are inheritance, polymorphism, abstraction and Encapsulation


4 0
3 years ago
The _________keys include the home, end, and arrow keys.
katovenus [111]
The answer would be Functional Keys.
8 0
3 years ago
How does a desktop work
Nezavi [6.7K]
<span>A </span>desktop computer<span> is a </span>personal computer<span> designed for regular use at a single location on or near a </span>desk<span> or table due to its size and </span>power requirements<span>. The most common configuration has a </span>case<span> that houses the </span>power supply<span>, </span>motherboard<span> (a </span>printed circuit board<span> with a </span>microprocessor<span> as the </span>central processing unit<span> (CPU), </span>memory<span>, </span>bus<span>, and other electronic components), </span>disk storage<span> (usually one or more </span>hard disk drives<span>, </span>optical disc drives<span>, and in early models a </span>floppy disk drive<span>); a </span>keyboard<span> and </span>mouse<span> for </span>input<span>; and a </span>computer monitor<span>, and, often, a </span>printer<span> for output. The case may be oriented horizontally and placed atop a desk or </span>vertically<span> and placed underneath or beside a desk.</span>
3 0
3 years ago
Read 2 more answers
Which of the following should you always check before getting into a car? select all that apply
IgorLugansk [536]

Answer: I think all of the above

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • * Declare a variablecalled "car" of type "Car", and initialise its value to a new instance of the "Car"class.
    9·1 answer
  • Which delivery model is an example of a cloud computing environment that provides users with a web based email service ?
    9·2 answers
  • Which of these symbols is a special character that is accessible only from the Symbol dialog box? A. © B. + C. é D.
    13·2 answers
  • A _________ is the broadcast of various types of media over the web.
    10·2 answers
  • When numbers are changed in cells that are involved in formula is the formulas are automatically
    14·1 answer
  • Oracion con punto focal​
    6·1 answer
  • What is the difference between word processing software and email?
    12·2 answers
  • Which of the following would be least effective?
    10·1 answer
  • The view that perceptual processes take place over time and can be thought of in terms of a software/hardware metaphor is known
    5·1 answer
  • What are the inputs that the model uses to make decisions?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!