subject

Langauge: Java The Animal class is given in Listing 13.7 in the book. Modify this class by implementing the Comparable interface and Cloneable interface. Add the weight property in the Animal class with getter and setter methods. The two animals are compared based on their weights. Use the following main method to run your test program.
public static void main(String[] args) {
Animal[] list = new Animal[5];
list[0] = new Chicken();
list[0].setWeight(4.5);
list[1] = new Tiger();
list[1].setWeight(46.6);
list[2] = new Chicken();
list[2].setWeight(1.5);
list[3] = (Animal)(list[0].clone());
list[3].setWeight(7.5);
list[4] = (Animal)(list[1].clone());
java. util. Arrays. sort(list);
for (int i = 0; i < list. length; i++) {
System. out. println("weight: " + list[i].getWeight());
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 12:30, umimgoingtofail
What is the difference between the internet and the world wide web?
Answers: 1
image
Computers and Technology, 24.06.2019 08:00, nataliamontirl4230
Java the manager of a football stadium wants you to write a program that calculates the total ticket sales after each game
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, ariyanadavid5989
1. which of these is not true about torsion bars? a. they can be used to adjust ride height b. they can be adjusted anytime since they don't affect alignment angles c. they attach between the frame and the lower control arm d. they twist to produce a spring effect
Answers: 1
image
Computers and Technology, 24.06.2019 12:10, breezer20042
What is it called during the editing process when the processor ensures that a character holding a coffee mug from one angle is holding the same mug in the same way when the shot switches to another camera at another angle? cinematography continuity technology prop use
Answers: 1
You know the right answer?
Langauge: Java The Animal class is given in Listing 13.7 in the book. Modify this class by implemen...

Questions in other subjects:

Konu
Mathematics, 01.03.2021 19:40
Konu
Mathematics, 01.03.2021 19:40
Konu
Mathematics, 01.03.2021 19:40