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
I need some cool things to do with windows command prompt.
STatiana [176]
I programmed in batch before so I know a lot of things!

You can ping a website to test your latency.

ping google.com

I have a ton of tricks in cmd (Command Prompt). Message me if you want.





7 0
3 years ago
In this problem, we explore some of the properties of the CRC. For the generator G (=1001) given in Section 5.2.3, answer the fo
allochka39001 [22]

Answer:

b

Explanation:

5 0
3 years ago
The performance of a client-server system is strongly influenced by two major network characteristics: the bandwidth of the netw
Rama09 [41]

Answer:

A bandwidth is the maximum rate of transfer of data across a given path

Latency refers to the delay of data to travel or move between a source and destination

An example of a high bandwidth and high latency network is the Satellite Internet connectivity.

An example of a low bandwidth and latency network is the telephone system connection.

Explanation:

Solution

Bandwidth: Bandwidth determines how fast data can be transferred for example, how many bits/sec it can transport.

Latency: It refers to the delay or how long it takes for data to travel between it's source and destination.

An example of a high bandwidth and high latency network is the Satellite internet connection.

Satellite internet connection: This is responsible for the connectivity of several systems, it has a high bandwidth, since satellite are in space, due to distance it has a high latency.

So, satellite internet connection is compensated with high latency and high bandwidth.

An example of a low bandwidth and low latency network is the Telephony network.

Telephone/telephony internet connection: This connection does not have much data for transfer. it has low size audio files of which a low bandwidth range. also for both end or end users to understand and talk to each other, it has low latency.

3 0
3 years ago
I need help in Jumbotron: Paragraph. The question is:
Aleksandr-060686 [28]
<span>.jumbotron p
{
color: #fff;
font-size: 20px;
}</span>
6 0
2 years ago
- Create a Java program in both Windows and Ubuntu using any of their Editors *** DO NOT USE IDE'S SUCH AS ECLIPSE, NETBEANS, ET
Marat540 [252]

Answer:

Following are the code to this question:

public class ArrayMath//defining a class ArrayMath

{

public static void main(String[] args) //defining main method

{

int x[][]=new int[10][10]; //defining a 2D array  

arrays(x);//calling a method arrays by passing an array

}

private static void arrays(int[][] x)//defining a method arrays

{

int odd_column_sum=0,sum_of_Elements=0,i,j,even=1;//defining integer variable  

for(i=0;i<x.length;i++)//defining loop for columns  

{

for(j=0;j<x[0].length;j++)//defining loop for rows

{

x[i][j]=i*j;//multiply the i and j value atore in array

}

}

System.out.println("::The 2D array :: ");//print message

for(i=0;i<x.length;i++)//defining loop for columns

{

System.out.print("\t");//use print method for line space and line break  

for(j=0;j<x[0].length;j++)//defining loop for rows

{

System.out.printf("%d\t",x[i][j]); //print array values

}

System.out.println( );//print for line break

}

for(i=0;i<x.length;i++) //defining loop for Columns

{

for(j=0;j<x[0].length;j++) //defining loop for rows

{

if(even%2!=0)//defining if block for check odd number condition

{

odd_column_sum+=x[j][i];//add odd number of array

}

sum_of_Elements+=x[i][j];//add even number of array

}

even++;//increment even variable value by 1

}

System.out.println("The sum of Odd Columns:"+odd_column_sum);//print odd_column_sum value

System.out.println("The array elements :"+sum_of_Elements);//print sum_of_Elements value

}

}

Output:

please find attached file.

Explanation:

In the above-given code, a class "ArrayMath" is defined, inside the class the main method is declared, which define a 2D array "x", this stores 10 columns and 10 rows and at the last, we call the arrays method by passing an array as a variable.

In the arrays method, integer variable, "odd_column_sum, sum_of_Elements, i, j, and even" is defined, in which variable "i and j" is used in the loop for calculating value, even is used to check odd column and then store its value in the "odd_column_sum" variable, and add whole element value is added into the "sum_of_Elements" variable.

8 0
3 years ago
Other questions:
  • What is something you can do to stay connected to the relationships in your life while we spend this time at home?
    13·1 answer
  • When will it be determined whether or not a donor's organs are fit for recovery and transplantation?
    10·2 answers
  • Write a function named get_my_age that returns your age as an int (this is YOUR age, so if you were 21 you would return the numb
    11·1 answer
  • C++ CODE
    6·1 answer
  • Fatal error: Class 'Drush\Commands\DrushCommands' not found in /Users/amy/testsite/Sites/acquia dev desktop/fresh-install/module
    7·1 answer
  • Brainliest to whoever answers this first, i need help explaining.
    8·1 answer
  • Yolanda first breaks down the whole game she needs to program into modules. She then breaks these modules into smaller modules u
    11·1 answer
  • Write a method body for the static method isDivisibleBy5 shown below. The only NaturalNumber methods you are allowed to use are
    12·1 answer
  • You have used loops for repetitive processes.
    11·1 answer
  • Which code snippet is the correct way to rewrite this in Semantic HTML?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!