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
What is a principle of DevOps?​
solong [7]

Answer:

the main principles of DevOps are automation, continuous delivery, and fast reaction to feedback. You can find a more detailed explanation of DevOps pillars in the CAMS acronym: Culture represented by human communication, technical processes, and tools.

4 0
3 years ago
_____ is a markup language designed to transport and store data on the Web. Group of answer choices Standard Generalized Markup
Kisachek [45]

<u>Extensible Markup Language (XML)</u> is a markup language designed to transport and store data on the Web.

Explanation:

  • Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable
  • Extensible means that the language is a shell, or skeleton that can be extended by anyone who wants to create additional ways to use XML.
  • Markup means that XML's primary task is to give definition to text and symbols.
  • It is a textual data format with strong support, Unicode for different human languages.
  • Extensible Markup Language (XML) is used to describe data.
  • The design goals of XML emphasize simplicity, generality, and usability across the Internet.
  • It is a text-based markup language derived from Standard Generalized Markup Language (SGML).
4 0
3 years ago
Why is the Singleton pattern commonly referred to as an “anti-pattern”?
snow_lady [41]

Answer:

Singleton pattern is the pattern for design that is build using the global variables which creates a lot of drawback in the designing. Singleton pattern are considered with the global variable and thus cannot be bound into single unit which complexes the components in design.

They have a loose coupled variables in design and also does not show the property of the multi-threading .These feature are responsible for the decrement in the performance and thus are not highly preferred choice for the pattern.So, it is known as the "anti- pattern".

3 0
3 years ago
A personal academic plan is a set of goals relating to the things you want to accomplish while you are in school.
Alex787 [66]

Answer:

True

Explanation:

8 0
2 years ago
Translating an algorithm into the syntax of Java is the design phase of software development.
Digiron [165]

Answer:

I think it's false

Explanation:

I don't think so. What makes me hesitate is that you may have been told that in your text or in the classroom.

Here are the steps as I understand them.

  1. Understand the problem you are trying to solve.
  2. Design a solution.
  3. Draw a flow chart.
  4. Write pseudo-code.
  5. Write code.
  6. Test and debug.

I think you've done the designing long before you start writing code or even pseudo-code.

4 0
2 years ago
Other questions:
  • What is the management part of a dashboard?
    10·1 answer
  • What is A wage paid based on the ability to sell a product or service is (a) _____.
    9·1 answer
  • Text that does not fit in a cell
    7·1 answer
  • Which one of these are a valid IPv4 address? Check all that apply.
    9·1 answer
  • An application programming interface (API) is ________. Select one: A. the code to interface between an application and RAM B. t
    15·1 answer
  • Use JavaWrite a program that will simulate a change machine found at cash registers. Input the amount due and amount paid from t
    12·1 answer
  • Multiply each element in origList with the corresponding value in offsetAmount. Print each product followed by a semicolon (no s
    15·1 answer
  • How to make a website
    15·2 answers
  • Direction: Write True on the line if the statement is correct. Write False if the statement is incorrect. 1. All objects are com
    13·2 answers
  • What has global css rulesets of an angular 8 project mcq.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!