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
Kruka [31]
3 years ago
14

Consider the code block below. What is the value of amount when this method is called twice, the first time using cookieJar(7) a

nd then using cookieJar(22)?
public static int cookieJar(int addCookies) {

int amount = 0;
amount += addCookies;
return amount;

}
A. 7
B. 15
C. 22
D. 29
E. An error occurs

Computers and Technology
1 answer:
RUDIKE [14]3 years ago
3 0

Answer:

C. 22

Explanation:

Given that the argument is being passed by value, there is no memory to consider.  So cookieJar(7) returns 7 and cookieJar(22) returns 22.

If the argument parameter was passed by reference or pointer, then perhaps the value from cookieJar(7) would be considered with cookieJar(22).

Note, this code block really isn't doing anything other than returning the value passed into it.  The "amount" variable is immediately set to 0, and then the value passed in is added to amount (which is 0), and returns.  The following code could replace this function:

public static int cookieJar(int addCookies){

return addCookies;

}

The above code will return an equivalent output to the given code.

Notice, the function is not dependent on any previous call, so the value for each is unique to the call itself, i.e., cookieJar(22) returns 22 and cookieJar(7) returns 7.

So, C. 22 would be correct.

You might be interested in
If anyone knows how to code on python:
Allushta [10]

Answer:

def dice_roller():

   # ask for first input

   input1 = int(input("Enter the first roll: "))

   # check if it's valid

   while input1 < 1 or input1 > 6:

       print("Invalid number")

       # ask for new input if the previous was invalid

       input1 = int(input("Enter the first roll: "))

   # ask for second input

   input2 = int(input("Enter the second roll: "))

   # check if it's valid

   while input2 < 1 or input2 > 6:

       print("Invalid number")

       # ask for new input if the previous was invalid

       input2 = int(input("Enter the second roll: "))

   # check of the numbers are the same

   if input1 == input2:

       print("You rolled the same numbers. Try again")

       # if they are the same call this function again to get new numbers

       dice_roller()

   else:

       # print how many spaces to advance

       print("Advance", input1+input2, "spaces")

if __name__ == '__main__':

   dice_roller()

Download txt
5 0
2 years ago
How many pounds must a sand bag weigh to test if a safety net can absorb the proper amount of force? A. 150 lbs. B. 200 lbs. C.
d1i1m1o1n [39]
The answer is 400 pounds.
6 0
2 years ago
Describe three general methods for passing parameters to the operating system.
const2013 [10]

a. Pass parameters in registers

b. Registers pass starting addresses of blocks of parameters

c. Parameters can be placed, or pushed, onto the stack by the program,  and popped off the stack by the operating system

8 0
3 years ago
str1=”Good” str2=”Evening” Does the concatenation of the above two strings give back a new string or does it concatenate on the
Lena [83]

Answer:

It gives a new string

Explanation:

In programming; when two or more strings are concatenated by a concatenating operator, the result is always a new string.

From the question, we have that

str1 = "Good

str2 = "Evening"

Let's assume that + is the concatenating operator;

str1 + str2 = "Good" + "Evening" = "GoodEvening"

The result of concatenating str1 and str2 is a new string "GoodEvening" while str1 and str2 still maintain their original string value of "Good" and "Evening"

5 0
2 years ago
External hard drives typically connect to a computer via an external port (such as a usb or ____ port) or a wireless connection.
Marianna [84]

External hard drives typically connect to a computer via an external port (such as a USB or <u>thunderbolt</u> port) or a wireless connection.

<h3>What is a hard drive?</h3>

A hard drive can be defined as an electro-mechanical, non-volatile data storage device that is made up of magnetic disks (platters) that rotates at high speed.

In Computer technology, all hard drives are commonly installed on computers and other digital service for the storage of digital files and to enable the booting of a computer through its operating system (OS).

<h3>What is a memory?</h3>

A memory can be defined as a terminology that is used to describe the available space on an electronic device that is typically used for the storage of data or any computer related information such as:

  • Images
  • Videos
  • Texts
  • Music
  • Codes
  • Folders

In conclusion, all external hard drives typically connect to a computer through an external port such as a USB, <u>thunderbolt</u> port, or a wireless connection.

Read more on hard drive here: brainly.com/question/26382243

#SPJ1

8 0
9 months ago
Other questions:
  • The technology (software) that automatically downloads website information to your computer is called ________.'
    15·1 answer
  • How to use javascript libraries in javascript code?
    9·1 answer
  • The Internet shopping cart is an example of which version of the web?
    15·1 answer
  • What do you believe are the motives of a cyber criminal? Why?
    15·1 answer
  • You are a network technician for a small corporate network. It's been decided that the office needs a wireless network for emplo
    6·1 answer
  • What was the technology that defined each of the four generations of computers?
    12·1 answer
  • To prepare a data character for transmission, a ____ bit is added to the beginning of the character and informs the receiver tha
    11·1 answer
  • What invention in the past do you think had a significant impact on our culture/ lifestyle? What do you think will be invented/
    11·1 answer
  • During system testing, developers test the program in an environment that is very similar to how the program will eventually be
    11·2 answers
  • What is computer assisted translation​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!