Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

A4. Given the following class diagram, interfaces 5 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. 1 2 interface Animal { int numberOf Legs(); } interface Mammal extends Animal { } interface Reptile extends Animal {} 7 8 10 class Cat implements Mammal { public int numberOf Legs() { return 4; } 1 12 class Tiger extends Cat { } 16 17 18 class Snake implements Reptile { public int number of Legs() { return 0; } } 20 21 > Animal numberOfLegs(): int > Mammal > Reptile Answer: A A Cat Snake |+numberOfLegs() : int |+numberOfLegs() : int Tiger I 1 Cat Snake |+numberOfLegs(): int +numberOfLegs() : int Tiger 1 2 3 public class Animals { public static void main(String[] args) { Animal animali, animal2, animal3; Mammal mammall; Cat cati; Snake snakel; Tiger tigeri; List listi, list2; 8 9 10 12 13 14 animals = new Tiger(); snake1 new Animal(); animal2 = new Animal(); cat1 = new Tiger(); mammal1 = new Snake(); tiger1 = mammall; animal3 = cati; 11st1 = new ArrayList(); 11st2 = new ArrayList(); 15 16 17 18 19 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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions