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
sashaice [31]
2 years ago
13

Assume that class BankAccount exists, and that it has a constructor that sets the private field balance, and that setBalance and

getBalance are defined by class BankAccount and set and get double values. Then what is the output of the following code:________.
a. 600.0
b. 0.0
c. 300.0
d. null
e. an error will result
Computers and Technology
1 answer:
Ainat [17]2 years ago
4 0
<h2>Question:</h2>

Assume that class BankAccount exists, and that it has a constructor that sets the private field balance, and that setBalance and getBalance are defined by class BankAccount and set and get double values.

Then what is the output of the following code?

BankAccount b1 = new BankAccount(600.0);

BankAccount b2 = b1;

b1.setBalance(300.0);

System.out.println(b2.getBalance() );

<h2>Answer:</h2>

300.0

<h2>Explanation:</h2>

The given snippet of code is as follows:

=======================================

BankAccount b1 = new BankAccount(600.0);

BankAccount b2 = b1;

b1.setBalance(300.0);

System.out.println(b2.getBalance() );

=======================================

<u><em>Line 1</em></u>: An object b1 of the BankAccount class is created which sets the value of its <em>balance </em> to 600.0

<u><em>Line 2</em></u>: A second object, <em>b2</em>, is created referencing or pointing to the first object, <em>b1 </em>in memory. It could also be interpreted to mean that a second object <em>b2</em> is created from the exact copy of the first object, b1. This is called <em>object cloning</em>. This by implication means that all the fields (including the contents of the fields) of the first object b1, are copied to b2 which also means that when there's a change in b1, an update is made to b2 also. If a change is made to b2, b1 also gets updated.

<u><em>Line 3</em></u>: Object <em>b1</em> is updated by setting the value of its <em>balance</em> field to 300.0 using the setBalance() method. This will also update the same field for the second object <em>b2.</em>

<em />

<u><em>Line 4</em></u>: The value of the <em>balance</em> field of object b2 is being printed to the console. Since the value has been updated in line 3 when that of b1 was updated, <em>300.0</em> will be printed to the console.

<em />

<em />

You might be interested in
Controlled intersections use some form of which of the following:
Genrish500 [490]
A.all of the above it is correct 
7 0
3 years ago
Who should get the copyright credit for a piece of computer art: the CPU, the software, or the programmer? Explain your reasonin
yulyashka [42]

Answer:

The programmer.

Explanation:

The CPU (central processing unit or simply the processor) is the brain of the computer system, it processes data at a very fast rate depending on it's processing speed. But it only relates to speed of data processing and a link between components of the system.

A software is a program code at executes a task in the system. It a logical and follows an algorithm to solve a given task. Computer systems do not generate  lines of code by itself, but instead, A programmer writes the code to create the software used by the system.

6 0
3 years ago
Which option ie an example of an html end tag
Kay [80]
Any end tag in HTML needs to look like this, the word body used in this example is one of the more important elements, but you can replace it to any real element in HTML:
i.e. </body>
8 0
3 years ago
Why is it important to record audio of silence in the area in which you are filming?
Serhud [2]

Answer:

To make sure that there is no other outside/excess noise while you are filming your actual film

Hoped this helped !

Cheers, Z

3 0
3 years ago
Read 2 more answers
The _______ displays the data series in separate columns side-by-side so that you can compare the relative heights of the column
k0ka [10]

Answer:

Cluster Column Charts.

Explanation:

Clustered column chart:-It displays multiple data series in separate vertical columns. Each series have the same axis labels.Clustered vertical columns thus allow direct comparison of multiple data series.When having three data series you can compare their heights also.So we conclude the answer is Cluster Column Charts.

3 0
3 years ago
Read 2 more answers
Other questions:
  • What aspect of the internet makes it fault-tolerant?
    6·1 answer
  • A computer’s memory is composed of 8K words of 32 bits each. How many bits are required for memory addressing if the smallest ad
    10·1 answer
  • Why is self-esteem important in self-representation
    7·1 answer
  • Use unit analysis to determine the unit of measurement for the expression 10x + 25y​
    8·1 answer
  • Which of the following is NOT considered a step in the problem solving process. A Try B Discover C Prepare D Define
    12·1 answer
  • Which feature is used to summarize data from multiple worksheets but does not require that the data be in the same location on e
    12·1 answer
  • Which option is used to ensure the integrity and authenticity of a Word document but requires additional services to be availabl
    5·2 answers
  • Why does every image on brainly look like this too me?? it started today
    15·2 answers
  • To determine what to study one Should first
    7·1 answer
  • after adding a sound to a slide, the audio tools tab will allow you to apply artistic effects and quick styles to your sound ico
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!