Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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?

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedundefined

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

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

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

=+2 Is the decision sustainable in the long run?

Answered: 1 week ago

Question

=+1 Is the decision fair to employees?

Answered: 1 week ago