Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

programing(java) A4. Given the following class diagram, interfaces and classes that model various kinds of animals. What will be the errors in the main method?

programing(java)
image text in transcribed
image text in transcribed
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 3 interface Animal { int numberor Legs(); } 4 5 G > Animal numberOfLegs(): int 7 interface Mammal extends Animal { } interface Reptile extends Animal ) class Cat implements Mammal public int number of Legs() { return 4; 9 10 12 > Mammal > Reptile 3 14 16 17 Cat class Tiger extends Cat () class Snake implements Reptile { public int numberOf Legs() { return 0; } ) 18 19 20 21 Snake +numberOfLegs(): int +numberOfLegs(): int Tiger 1 7 R 9 10 public class Animals { public static void main(String args) { Animal animali, animal2, animal3; Mammal mammall; ; Cat cat1 Snake snake; Tiger tiger List listi, list2; animali new Tiger(); snaket - new Animal(); animal2 - new Animal(); cat1 = new Tiger(); mammalt = new Snake(); tiger1 = mammalt animal3cati; 11st1 = new ArrayList(); 11st2 = new ArrayList(); } } 12 13 14 15 16 1 17 18 10 20

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions