subject

Consider the following Java class. Recall that x instanceof C tells you whether the dynamic type of x is C or a subtype of C.
class Coin {
private double value;
private double weight;
public void setValue(final double value) { this. value = value; }
public double getValue() { return value; }
public double getWeight() { return weight; }
public Coin(final double value, final double weight) {
this. value = value;
this. weight = weight;
}
public boolean equals(final Object that) {
return (that instanceof Coin) &&
(this. weight == ((Coin) that).weight);
}
}
a) TRUE or FALSE: The equals method does not care about the weight of the coin because coins are compared based on their face value.
b) Given the above Coin class, what is the output of the following code?
final Coin n1 = new Coin(0.05, 5.0);
final Coin n2 = new Coin(0.05, 5.1);
System. out. println(n1.equals(n2) + " " + (n1 == n2));
// answer here ->
n2.setWeight(5.0);
System. out. println(n1.equals(n2) + " " + (n1 == n2)); ));

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
Amanda needs to create an informative print brochure for her local library’s fundraiser dinner. what critical detail must she have before she starts designing the brochure?
Answers: 1
question
Computers and Technology, 24.06.2019 08:20
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
question
Computers and Technology, 24.06.2019 13:30
In the rgb model, which color is formed by combining the constituent colors? a) black b) brown c) yellow d) white e) blue
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
Which of the following processes applications across multiple computing devices? a. functional application b. distributed system c. workgroup information silo d. information silo
Answers: 3
You know the right answer?
Consider the following Java class. Recall that x instanceof C tells you whether the dynamic type of...
Questions
question
Mathematics, 01.07.2019 20:50
question
Spanish, 01.07.2019 20:50
Questions on the website: 13722362