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
Which Internet Explorer security zone includes all Internet Web sites that are not specifically assigned to another zone?
Anna007 [38]

Answer:

Internet is the correct answer for the above question.

Explanation:

  • The Internet Explorer define some security zone (which includes the Restricted sites, internet, Trusted sites, and Local intranet) which is used to block the unwanted sites which can be opened by some other websites.
  • When any user use any website, sometimes that websites open different websites. This security zone gives the features to secure the user from this event.
  • There are four-zone which are described in the first line, in which the internet zone is used to take all the websites which are not defined for the other security zone. It means that when any user does not decide the security zone for any websites then by default it comes in the internet zone.
  • This is also asked by the question, Hence "internet" is the correct answer.
4 0
2 years ago
Suppose you have two tables: officer and gentleman. what question(s) can be asked by using the union operator?
Alik [6]
The union of two tables is basically the total of the two tables, so "or" questions would be my guess.
8 0
2 years ago
This may vary in your state, but S/P2 recommends keeping all environmental documentation a minimum of:
Anettt [7]

A would be the answer!!!...

4 0
3 years ago
Read 2 more answers
A user cannot connect to any devices outside of the current network. Which device should a technician check first for problems?
tatiyna

Answer:

DHCP server

Explanation:

The first option that we must check is the DHCP server (The Dynamic Host Configuration Protocol) server because this is the protocol that gives us the IP addresses to connect with the internet if we don't have an IP (Internet Protocol) address,  we can never have an internet connection, if the DNS fails we cannot connect with the internet, but regularly the DHCP is the main issue if there are not physical issues.

4 0
3 years ago
If more than 4 feet of track is needed, at least one additional support must be installed for every extension of ___ feet or les
Elena-2011 [213]

If more than 4 feet of track is needed at least one additional support must be installed for every extension of <u>4 </u> feet or less.

<h3>What is Feet in Electrical Installation system?</h3>

In the electrical installation system, the inside wall of a system e.g

  • indoor spa or
  • indoor pool

is usually grounded or GFCI protected (A ground fault circuit interrupter) for indoor convenience.

For a chosen electrical outlet, the maximum receptacle distance in a household must be at least 12 feet apart using floor line measurement.

From the given question:

  • If more than 4 feet of track is needed at least one additional support must be installed for every extension of <u>4 </u> feet or less.

Learn more about electrical installation systems here:

brainly.com/question/24786034

3 0
2 years ago
Other questions:
  • A file to which information is written is referred to as a(n) ____ file.
    8·1 answer
  • __________ was awarded the Nobel Prize in physics forhis work on the photoelectric effect.
    13·1 answer
  • Help me plase will give brainliest
    12·2 answers
  • Users of an access point share the transmission capacity of the access point. The throughput a user gets is called the ________.
    11·1 answer
  • John’s grandparents make wine for special occasions. They add a pinch of yeast to crushed grapes. Over time, this action release
    15·2 answers
  • Draw a circuit with a 12-volt battery, a 100 ohms resistor in series, and two resistors (each of value 200 ohms) in parallel. Wh
    9·1 answer
  • Can someone help me with this project im confused
    14·1 answer
  • Each sentence in the paragraph below has a number. Choose the number of two sentences that are in the wrong order in this story.
    14·1 answer
  • Is it better to try to prevent damage from natural disasters or to deal with disasters after they occur?
    10·2 answers
  • Solve this for brainlest​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!