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
In javascript, what can I put after player. to make my character go in the center of the screen? like example:
melamori03 [73]

Answer:

0,0

Explanation:

you could try to use the x-axis and y-axis to put your character in a certain place. I'm not totally sure if that is how javascript works, but for the x-axis and y-axis, the center is always(0,0).

6 0
3 years ago
4. Computer processing work that is split between a desktop computer and a more powerful computer that processes and stores shar
jeyben [28]

Answer:

A. client/server

Explanation:

Beacuse a Server or a client is what hold data for big companies like google and microsoft

7 0
3 years ago
1. What are copyright laws?
andre [41]
1. Copyright laws protects original works of authorita1. A
7 0
3 years ago
Read 2 more answers
Why is it important to understand the basic ways in which pictures and video are stored in the computer?
nalin [4]

Answer:

This is important to understand the basic ways to store pictures and video in a computer because both of them consume a relatively large storage spaces in a the computer compared with normal text files.

Explanation:

Nowadays, many computers shipped with a SSD drive (Solid State Drive) with only around 256 - 512 Gb. With this capacity, the storage spaces left to store the pictures and video are very limited after installation of the essential software.

One common way to store pictures and video is to save them at an external hard drive. Another option is the cloud storage service such as Google Drive, Google Photo etc. These storage mediums obviate the need to store those media files into the local computer machine.

6 0
3 years ago
Which of the following is NOT a safety practice for working near power lines?
dimulka [17.4K]
The answer is use rider posts, when available, to avoid getting too close to the power line. 

I hope this helps!  
5 0
3 years ago
Other questions:
  • PLS HURRY!! This OS introduced a very cool GUI that had animations and transparencies.
    5·1 answer
  • Write a converter program for temperatures. This program should prompt the user for a temperature in Celsius. It should then con
    10·1 answer
  • A file that contains program code is called a ____________.
    13·1 answer
  • What is the term used for describing the judgement or common sense part of problem solving​
    11·1 answer
  • Joann wants to insert page numbers at the bottom of the pages of her document using the Field option in Quick
    12·2 answers
  • I need 3 sentences on adware.<br> What they do and how they are a risk.
    5·1 answer
  • Which expression is equivalent to 3x + 3x + 3x?<br><br> From Performance Matters
    11·2 answers
  • The Last Free brainliest<br><br> This Is The Last Brainliest That Im Doing Forever Sorry Guys
    8·2 answers
  • Select the correct answer.
    13·2 answers
  • What should you do first when designing a program?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!