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
The _______ valve protects the air pump from reverse-exhaust pressure.
alexandr402 [8]
D. The answer for this is the gulp
7 0
2 years ago
Effective presentations vary the color scheme on each slide.<br><br> True<br> False
KengaRu [80]

Answer:

TRUE

Explanation:

7 0
2 years ago
Read 2 more answers
Compare GBN, SR, and TCP (no delayed ACK). Assume that the timeout values for all three protocols are sufficiently long such tha
kvv77 [185]

Answer and Explanation:

a)

For Go-Back-N:

  Host A sent total number of segments is 9.The initial segment numbers are 1,2,3,4,5 and re-sent the segemnts 2,3,4 and 5 because 2nd segment was lost.

Host B sent the number of ACKs are 8.Host B sent ACKs 1 by four times because 2nd segment was lost and sent 4ACKs with sequence numbers 2,3,4 and 5

selective repeat:

 Host A sent total number of segments is 6.The initial segment numbers are 1,2,3,4,5 and re-sent the segemnts 2 because 2nd segment was lost.

Host B sent the number of ACKs are 5.Host B sent four ACKs with sequence numbers 1,3,4,5 and re-sent ACK2 with sequence number 2 because 2nd segment was lost.

TCP :

Host A sent total number of segments is 6.The initial segment numbers are 1,2,3,4,5 and re-sent the segemnts 2 because 2nd segment was lost.

Host B sent the number of ACKs are 5.Host B sent four ACKs with sequence number 2 and There is one ACK with sequence number 6.TCP always send an ACK with expected sequence number

b) If the timeout values for all three protocol are much longer than 5*RTT,then TCP protocol successfully delivers all five data segments in shortest time interval.

 

4 0
3 years ago
Given two variables matric_age and grad_age, write a statement that makes the associated value of grad_age 4 more than that of m
bearhunter [10]

Answer:

grad_age=matric_age+4

Explanation:

As mention in the question their are two variable matric_age and grad_age respectively .The grad_age variable store the value of 4 more than that of matric_age i.e (matric_age+4) means that it store the value 4 plus matric_age Suppose a matric_age is initialized with 4 then value of grad_age=4+4=8.

8 0
3 years ago
What is distribution hardware?
saveliy_v [14]
A distributed computer system consists of multiple software components that are on multiple computers, but run as a single system. The computers that are in a distributed system can be physically close together and connected by a local network, or they can be geographically distant and connected by a wide area network.
4 0
3 years ago
Other questions:
  • How can I use the internet/social media to protect my identity?
    14·1 answer
  • Why would a brokered CD pay more than a regular CD?
    13·1 answer
  • A light or optical microscope most commonly used is called a(n) _____. bright-field microscope dark-field microscope electron mi
    8·2 answers
  • How do you add a PDF assignment to google docs and be able to edit it?
    13·1 answer
  • PLEASE HELP! One of the nice byproducts of joining a club, organization, community service project, or service learning project
    6·1 answer
  • Why bootable installer preparation is important? explain
    9·1 answer
  • The __________ operator increases the value of the variable by 1 after the original value is used in the expression in which the
    7·1 answer
  • Write a program that reads a file that contains only integers, but some of the integers have embedded commas, as in 145,020. The
    10·1 answer
  • Merging refers to dividing a single cell into multiple cells. *TrueFalse
    14·1 answer
  • What is the output for this program?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!