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]
3 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]3 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
A _____ describes two or more computers connected to each other.
WARRIOR [948]

Answer:

Computer network.

Since it is 2 or more computers connected together.

5 0
3 years ago
Read 2 more answers
What is the name of the most common connector type used for providing power to various hardware components inside computer case?
user100 [1]
The answer is the molex.
4 0
4 years ago
What are the "..........." called leading up to a page number?
ANTONII [103]
Contents i guess don't be mad if i get it wrong otay
5 0
3 years ago
How does an ip address allow your computer to be reached
LiRa [457]
Not sure if this helps

The "IP" part of IP address stands for "Internet Protocol." The "address" part refers to a unique number that gets linked to all online activity you do...somewhat like a return address on a letter you'd send out. (All this happens in milliseconds.)
Your computer is hooked up to the Internet, one way or the other. When you go online for email, to shop or chat, your request has to be sent out to the right destination, and the responses and information you want need to come back directly to you.

An IP address plays a significant role in that.

You and your computer actually connect to the Internet indirectly: You first connect to a network that is 1) connected to the Internet itself and 

8 0
3 years ago
Which of the following helps create a positive community?
Lera25 [3.4K]

Answer: D.) all of the above

Explanation: By doing all three of these it makes almost everyone in the community is happier and more positive which is better than the bully's & people who don't speak up feel less entitled, it achieves the goal.

5 0
3 years ago
Other questions:
  • In a PowerPoint presentation, it is not possible to add notes that are hidden from the audience's view.
    9·1 answer
  • What are sums of money that are given out for specific reasons?
    5·2 answers
  • What type of link is used to call this file shown below?
    5·1 answer
  • You are setting up a RAID system in a server designed for optimum fault tolerance, accuracy, and minimal downtime. Which HDD is
    7·1 answer
  • PLEASE HELP 98 POINTS!!!!!!!!!!!!!!!!!!
    12·2 answers
  • A commuter swipes a public transport card at a kiosk and sees his account balance displayed on the screen. The commuter would be
    8·1 answer
  • What is hub.pls ans from pic. for computers​
    9·2 answers
  • Give two differences between ergonomic keyboard and standard keyboard?​
    9·1 answer
  • Sean is studying at a friend's house and notices that he can connect to the wireless network without entering a wireless network
    13·1 answer
  • When adopting and implementing a software as a service (saas) platform such as salesforce for your business, which responsibilit
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!