Question: Given the following class diagram, interfaces and classes that model various kinds of animals. What will be the errors in the main method? For each

Given the following class diagram, interfaces and classes that model various kinds of animals. What will be the errors in the main method? For each error, indicate the line number of each incorrect statement and explain in one sentence why it is wrong.

Given the following class diagram, interfaces and classes that model various kinds

of animals. What will be the errors in the main method? For

each error, indicate the line number of each incorrect statement and explain

> Animal numberOfLegs(): int > Mammal > Reptile A Cat +numberOfLegs(): int Snake +numberOfLegs(): int Tiger 4 interface Animal { int numberOf Legs(); 2 4 G 5 interface Mammal extends Animal { } 7 interface Reptile extends Animal { } class Cat implements Mammal { public int number of Legs() { return 4; } ) 10 12 13 14 16 17 18 19 20 21 class Tiger extends Cat class Snake implements Reptile { public int numberOf Legs() { return 0; ) ) public class Animals { public static void main(String[] args) { Animal animali, animal2, animal3; Mammal mammalt; Cat cat1; Snake snake1; Tiger tigeri; List list1, 11st2; 9 10 animali - new Tiger(); snake - new Animal(); 12 animal2 = new Animal(); 13 cat1 -new Tiger(); mammalt = new Snake(); tiger1 - mammall; animal3 - cati; listi = new ArrayList(); 18 list2 = new ArrayList(); 19 } 20} 16

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!