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
Serhud [2]
3 years ago
14

Write a public member function which replace that replaces one occurrence of a given item in the ArrayBag with another passed as

an argument. The method should return a boolean to indicate whether the replacement was successful.
Computers and Technology
1 answer:
ira [324]3 years ago
5 0

Answer:

The method is written in Java

public static boolean abc(int [] ArrayBag,int num, int replace){

    Boolean done = false;

    for(int i =0; i<ArrayBag.length;i++){

        if(ArrayBag[i] == num){

            ArrayBag[i] = replace;

            done = true;

        }

    }

    for(int i = 0;i<ArrayBag.length;i++){

        System.out.println(ArrayBag[i]+" ");

    }

    return done;

}

Explanation:

The method is written in java

The arguments of the method are:

<em>1. ArrayBag -> The array declares as integer</em>

<em>2. num -> The array element to check the presence</em>

<em>3. replace - > The replacement variable</em>

This line defines the method as boolean.

public static boolean abc(int [] ArrayBag,int num, int replace){

This line declares a boolean variable as false

    Boolean done = false;

The following iterates through the elements of the array

    for(int i =0; i<ArrayBag.length;i++){

This checks if the array element exist

        if(ArrayBag[i] == num){

If yes, the array element is replaced

            ArrayBag[i] = replace;

The boolean variable is updated from false to true

            done = true;

        }

    }

The following iteration prints the elements of the array

<em>     for(int i = 0;i<ArrayBag.length;i++){</em>

<em>         System.out.println(ArrayBag[i]+" ");</em>

<em>     }</em>

This prints returns the boolean thats indicates if replacement was done or not.

    return done;

}

<em>Attached to this solution is the program source file that includes the main method of the program</em>

Download txt
You might be interested in
manufacturers are making an effort to build energy-efficient computers and use recyclable cases and packaging true or false
Fittoniya [83]
True would be ur answer

Hope I helped:P
7 0
3 years ago
What are the three main purposes of an operating system? Explain how the old mainframe computers were different from the compute
lbvjy [14]

Answer:(1) To manage the computer's resources, which includes central processing unit, memory, disk drives, and printers, (2) To establish a user interface

(3)To execute and provide services for applications software.

The old mainframe computers have

(1) low memory sizes

(2) slower connectivity speed

(3) Larger sizer

(4) low sophistication.

Explanation: Operating system is a system software that manages the computer resources,helps to establish user interface and it helps to provide services for application softwares.

Operating system software includes WINDOWS X,WINDOWS 7,WINDOWS 8,LINUX,etc.

Mainframe computers are computers used by large multinational companies for processing bulk data. Old mainframe computers were produced by IBM(INTERNATIONAL BUSINESS MACHINE) in the year 1952 they are classed two scientific and commercial mainframe computers with different information although they had some incompatibilities. Old mainframe computers are large in size with low processing speed, sophistication and storage compared to present day system.

3 0
3 years ago
Which of the following changes the features (e.g., thickness of the line, shadow, 3-D effect, single or double, etc.) of the bor
lilavasa [31]
Border style
I hope it’s work
8 0
3 years ago
A computer emergency response team is called at midnight to investigate a case in which a mail server was restarted. After an in
ANEK [815]

<u>Answer</u>:   B. Identify the source of the active connection

<em>Any problem can be fixed only finding of the source of it. We can fix a problem in ‘n’ number of ways but it might again come back if source of it is not identified.</em>

<u>Explanation:</u>

Identify the source of the active connection is the NEXT step the team should take. It is very similar to our human body.

If the infection is coming in the body again and again and gets fixed in the treatment, the reason for come - back will be identified so that it does not <em>lead to unnecessary treatment. </em>

In a similar way, if source are identified then the problem of come-back can be avoided. <em>So option B would be the right choice.</em>

4 0
3 years ago
What is an example of technology that helps support the idea of continental drift.
docker41 [41]

I don't know technology, but using Satellite images, we are able to see that the continents once fitted into one 'jigsaw'. This shows that the continents must have drifted to its original place. Furthermore, Geothermal stations have pointed out convection currents in the Earth's mantle has caused the movement of crusts.
8 0
3 years ago
Other questions:
  • Which of the following activities poses the greatest personal cybersecurity risk? A. Making a purchase on an online store that u
    13·1 answer
  • After you select a cell with an error indicator, you can click the error checking _______ to display additional information abou
    14·1 answer
  • Which statement will properly start the main() function? def main(): def Main def main# def main[]
    14·2 answers
  • private int product(int n) { if(n &lt;= 1) return 1; else return n * product(n-2); } What is the output when product(6) is calle
    6·1 answer
  • Select the correct answer.
    15·2 answers
  • Calculate the total and average number from 1 to 100<br>​
    12·1 answer
  • 我对汉语的兴趣 làm đoạn văn theo đề trên​
    14·1 answer
  • Which type of evidence should victims collect to help officials catch cyber bullies?home addressesbirthdayssocial media username
    15·1 answer
  • Please list 15 safety rules that you think should be practiced in the Computer Technology classroom/lab.
    12·1 answer
  • 3. It is important to make certain that your employees are aware of the work ethic
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!