Animal class Create a simple class called Animal instantiated with a name and a method toString which...

70.2K

Verified Solution

Question

Programming

Animal class

Create a simple class called Animal instantiated with a name anda method toString which returns the name.

Cat class

Create a simple class Cat which extends Animal, but adds no newinstance variable or methods.

RedCat class

Create a simple class RedCat which extends Cat, but adds no newinstance variable or methods.

WildCardTester class

Create a class with the main method and methods addCat,deleteCat and printAll as follows.

addCat method

Has two parameters, an ArrayList with a lower bound of RedCat,and a String with the name of a Cat. Adds the identified Catreference to the ArrayList, and prints out a line as shown in thesample output below.

deleteCat method

Has two parameters, an ArrayList with an upper bound of Cat, anda String with the name of a Cat to be deleted. Deletes theidentified Cat reference to the ArrayList, and prints out a line asshown in the sample output below.

printAll method

Has a single parameter of an ArrayList with a wildcard type.Prints out all the items in the ArrayList.

main method

Create two ArrayLists, one for Animal, and one for RedCat.

Use addCat to add “Tiger” to the animal ArrayList.

Use addCat to add “Tom”, “Siamese” and “Tiger” to the redCatsArrayList.

Use printAll to print the list in the animal ArrayList.

Use printAll to print the list in the redCat ArrayList.

Use deleteCat to delete the first item in the redCatArrayList.

Use printAll to print the list in the redCat ArrayList.

Sample Output:

Cat Added named Tiger was added

Cat Added named Tom was added

Cat Added named Siamese was added

Cat Added named Tiger was added

The list of animals:

Tiger

The list of redCats:

Tom Siamese Tiger

Removed cat named Tom

The list of redCats after a deletion:

Siamese Tiger

Answer & Explanation Solved by verified expert
3.9 Ratings (647 Votes)
ProgramScreenshotsAnimaljavaCatjavaRedCatjavaWildCardTesterjavaProgram CodeAnimaljavaCreate a simple class called Animal instantiated with a nameand a method toString which returns the namepublic class Animal String name public AnimalString name thisname name Override public    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students