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
hich type of denial of service (DoS) attack occurs when a name server receives malicious or misleading data that incorrectly map
shusha [124]

Answer:

DNS poisoning

Explanation:

This type of attack is known as DNS poisoning it is a very common attack that focuses on trying to redirect users of the site that has been attacked towards fake servers. These fake servers belong to the attackers and are used to collect the user's private data, which can then be used by the attackers for a wide range of malicious acts. Aside from stealing user information, this malicious data travels alongside regular user data allowing it to infect various servers easily.

7 0
3 years ago
Which two factors mainly affect ocean tides on earth?
Troyanec [42]
Earths revolution about both the moon and the sun the moon the sun pull of distant planets
4 0
3 years ago
1.-  POR QUE LOS HUMANOS NOS INTERESAMOS EN ROBOTS CONASPECTO HUMANO?
oksian1 [2.3K]

Answer:

........

Explanation:

s

6 0
3 years ago
Flowchart in programming
ArbitrLikvidat [17]

Answer:

?

Explanation:

7 0
2 years ago
The best time to visit a college is: A. during spring break. B. on a weekend. C. when the college is in session. D. during winte
GaryK [48]
When the college is in session
5 0
3 years ago
Read 2 more answers
Other questions:
  • Which computer device works like the human central nervous system by connecting all the computer’s parts together and allowing t
    9·1 answer
  • Over time, programming languages have evolved in phases called ________.
    5·2 answers
  • Discussion group may have a___________ who monitors the postings and enforces the sides rules​
    13·1 answer
  • The second row of letters on the keyboard is called the______ row
    14·2 answers
  • A _______ is smaller than a notebook or laptop and has a touchscreen and sometimes a pointing device.
    13·1 answer
  • Trina Hauger works for Johnson Electric as a corporate lawyer, and part of her duties are to ensure the ethical and legal use of
    13·1 answer
  • Is full dive vr possible and can we accomplish it with today’s technology? Explain why
    13·2 answers
  • Where can we buy a cryptocurrency? from below options
    11·1 answer
  • What does the statement that follows do? double gallons[6] = { 12.75, 14.87 }; a. It assigns the two values in the initializatio
    13·1 answer
  • ANSWERED CORRECT BELOW
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!