Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a base class called Animal, that has fields, constructors, and anything else you think you may need as you go along. It should also

Create a base class called Animal, that has fields, constructors, and anything else you think you may need as you go along. It should also have a method called speak(), to make the Animal say something (using System.out.println)

Create any two subclasses of the Animal class. Each subclass must have the following:

  • At least one new field, with getter/setter methods
  • A default constructor that sets its fields to default values, and also all the fields of it's base class to default values
  • A parameterized constructor that accepts all fields from both the base (Animal) and new subclass fields
  • Override the speak method to make it say something specific that an object of that class would say.

Create another subclass that extends any one of the two subclasses from step 2.The subclass in step 2 will serve as a super class for this new subclass. Each subclass must have the following:

  • At least one new field, with getter/setter methods
  • A default constructor that sets its fields to default values, and also all the fields of it's base class to default values
  • A parameterized constructor that accepts all fields from both all super classes, and new subclass fields
  • Override the speak method, to make it say something specific that an object of that class would say.

In a main method, create an Animal object, and at least one object of each subclass (3 objects), and stick all the objects in either an ArrayList or an array. Then just loop through (iterate) the ArrayList or array, and call the speak method for each object

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

Mysql Examples Explanations Explain Examples

Authors: Harry Baker ,Ray Yao

1st Edition

B0CQK9RN2J, 979-8872176237

More Books

Students also viewed these Databases questions