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
What is the shortcut key to create a new desktop ​
Rom4ik [11]

Answer:

Win + Ctrl + D

Explanation:

Stay safe, stay healthy and blessed.

Have a good day !

Thank you

6 0
2 years ago
Read 2 more answers
Difrent between computer and computer system​
vampirchik [111]

Answer:

hope it helps..

Explanation:

a computer exists in a single place and does a primitive set of functions. A computer system combines a computer with many other things to perform a complex set of functions. It can also exist in a single place, but it may exist in many places at the same time.

HAVE A NICE DAY

3 0
3 years ago
With a(n) ____ structure, you perform an action or task, and then you perform the next action in order.
e-lub [12.9K]
The answer is a <u>sequence structure</u>
8 0
3 years ago
What is better for the sd card use as portable storage or use as internal storage?
Sever21 [200]
It depends on what you’d need it for.

> Portable Storage <
- Good for traveling.
- Good for porting stuff from a device to another device.

> Internal Storage <
- Better if you are using it for one device.
- Increase device storage.
5 0
3 years ago
How serious are the risks to your computer security?
ASHA 777 [7]

The seriousness of  the risks to your computer security is not to be a severe one. This is because Computer security risks  are due to the handwork of  malware such as, bad software, that can infect a  computer, and make the hacker to destroy your files, steal your data, or even  have access to your system without one's knowledge or authorization.

<h3>What are the risk results for information and computer security?</h3>

The term “information security risk” is known to be those  damage that occurs due to  an attacks against IT systems. IT risk is made up of a wide range of potential events, such as data breaches, regulatory enforcement actions, financial costs, and a lot more.

Some Examples of malware are viruses, worms, ransomware, spyware, and a lot others.

Hence, The seriousness of  the risks to your computer security is not to be a severe one. This is because Computer security risks  are due to the handwork of  malware such as, bad software, that can infect a  computer, and make the hacker to destroy your files, steal your data, or even  have access to your system without one's knowledge or authorization.

Learn more about computer security from

brainly.com/question/12010892

#SPJ1

6 0
2 years ago
Other questions:
  • &gt;
    6·1 answer
  • Elizabeth works for a local restaurant at the end of her shift she read she’s required to write in the time that she arrived in
    9·1 answer
  • Although you can use a dialog box to indent paragraphs, word provides a quicker way through the ____.
    7·1 answer
  • How many bytes of information can be stored on a hard drive?
    7·1 answer
  • The loss of privacy data has implications:
    5·1 answer
  • Whats the wire that connects to the wifi box
    15·2 answers
  • Think about some of the most memorable and forgettable games ever created. They can be games that were discussed in this unit or
    10·1 answer
  • Do pc players ever go outside?
    11·2 answers
  • Susan discovers the following log entries that occurred within seconds of each other in her Squert (a Sguil web interface) conso
    13·1 answer
  • The ______ process retains copies of data over extended periods of time in order to meet legal and operational requirements.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!