Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.image text in transcribed

1 2 interface Animal int number of Logs(); 4 5 > Mammal ) > Reptile 4 4 15 class Tiger extends Cat () class Snake implements Reptile { public int number or Logs({ return 0; Cat +numberOfLegs(): int Snake +numberOfLegs(): int 20 21 } Tiger 1 9 4 public class Animals public static void main(String[] args) { Animal animali, animal2, animal3; Mammal tamall; Cat cat1; Snake snake Tiger tigert; List listi, list2; 5 7 9 10 19 181 Answer: animali - new Tiger(); snake - new Animal(); animal2 = new Animal(); cati = new Tiger(); nannal1 = new Snake; tiger - mannali; animal3 - cata; 11sti = new ArrayList(); list2 = new ArrayList(); 10 Programming - Final Exam-Fall 20 Page 5 of 10 IN 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

More Books

Students also viewed these Databases questions

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago