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
kifflom [539]
3 years ago
9

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:
Alex787 [66]3 years ago
4 0

Answer: 29

Explanation:

The variable amount is given a initial value of 0

Therefore, the first method call:

cookieJar(7)

amount + cookieJar

amount = 0 + 7 = 7

And the value of 7 is returned for amount at the start of the block

Thus, when cookieJar is called the second time ;

cookieJar(22)

amount + cookieJar

amount = 7 + 22 = 29

And the value of 29 is returned for amount at the start of the block

You might be interested in
2. Design a class named Sandwich with data fields for description and price. Include a constructor that requires arguments for b
marta [7]

Answer:

The answer files have been attached below, with the description of the files in the explanation.

Explanation:

The Sandwich class contains two functions

1) Sandwich() : A constructor that takes two arguments, the Description of sandwich and its price.

2) display_Data(): A function that does not take any arguments, and does not return anything. It prints the states (data of the variables Description, Price )

The Delivery Sandwich has three functions:

1) DeliverySandwich(): A constructor that takes in three arguments, Description of sandwich, Its price, and the delivery address.

super key word is used to access the parent class. super() is a method of calling the parent class's constructor. Description and price are passed to parent class's constructor, where as DeliveryAddress is initialized in the DeliverySandwich constructor.

It is then checked whether the price is greater than 15. If it is, the deliveryfee is set to 3, otherwise it is set to 5.

2) display_Data()

This is an overridden function. An overridden function in java is a function that has the same name as another function in its parent's class, but has different functionality.

The function first calls the display_Data() of the parent class using super.display_Data() to display the price and description of sandwich, then prints the address and delivery price of the sandwich

3) main()

Driver code that has objects of both sandwiches. Once an object is created, the display data function is called of each class to see the states of the variables in them.

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
5 0
3 years ago
JAVA
qwelly [4]

public class MyClass {

   public static void main(String args[]) {

     int x = 1;

     int total = 0;

     for (int i = 1; i <= 10; i++){

         x *= i;

         total += x;

     }

     System.out.println(total);

   }

}

This program finds the sum of that series to the tenth term, the sum is: 4037913. I hope this helps.

6 0
3 years ago
You're expecting visitors who will be demanding Mamet access Before they arrive, you can activate a Guest network that has its o
fgiga [73]

functions

is the correct answer of your question ^_^

8 0
3 years ago
How to can you avoid becoming a victim of identity theft?
dusya [7]

Reduce the number of credit and debit cards you carry in your wallet. <em>I</em> recommend that you do not use debit cards because of the potential for losses to your checking account. Instead, carry one or two credit cards and your ATM card in your wallet. Nonetheless, debit cards are popular. If you do use them, take advantage of online access to your bank account to monitor account activity frequently. Report evidence of fraud to your financial institution immediately.

5 0
4 years ago
What is a template class in c++?
AURORKA [14]
Install Visual Studio 2017 and install the C++ pack and you have access to the templates (function and class)
7 0
3 years ago
Other questions:
  • Building relationships during your career exploration is called
    9·2 answers
  • How are publishing used
    10·1 answer
  • In statistics, what is the mode of a data set?
    6·2 answers
  • Which key is used in word processors to create indentations?
    13·2 answers
  • Two groups of simple machines and list the simple machines that belong in each group
    7·1 answer
  • Which remote access configuration option should you choose if you want mobile users to be able to make a secure connection to th
    9·2 answers
  • Jamie is preparing a presentation on his laptop for his college annual event. He inserts audio and video files into the presenta
    11·2 answers
  • Using the given definition of the Measurable interface: public interface Measurable { double getMeasure(); } Consider the follow
    10·1 answer
  • How would asking questions or defining problems be used in this career?<br> -
    13·1 answer
  • A capacitor of capacitance 102/π µF is connected across a 220 V, 50 Hz A.C. mains. Calculate the capacitive reactance, RMS value
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!