Question: undefined A4. Given the following class diagram, interfaces and classes that model various kinds of animals. What will be the errors in the main method?
undefined
A4. 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. 5 1 2 interface Animal { int numberOf Legs(); } 4 interface Mammal extends Animal {} 6 > Animal numberOfLegs(): int interface Reptile extends Animal { } 7 8 9 10 11 class Cat implements Mammal { public int numberOf Legs() { return 4; 3 1 12 13 > Mammal > Reptile 14 16 16 A class Tiger extends Cat { } 17 IN 1 Cat +numberOfLegs(): int class Snake implements Reptile { public int number of Legs() { return 0; } ) Snake +numberOfLegs(): int 19 20 21 Tiger 1 2 public class Animals { public static void main(String[] args) { Animal animali, animal2, animal3; Mammal mammall; Cat cat1; Snake snakes; Tiger tiger1; List
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
