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

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

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!