Question: WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a method toString which returns the name. Cat class

WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a method Sample Output: Cat Added named Tiger was added Cat Added named Tom was added Cat Added named Siamese was

WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a method toString which returns the name. Cat class Create a simple class Cat which extends Animal, but adds no new instance variable or methods. RedCat class Create a simple class RedCat which extends Cat, but adds no new instance variable or methods. Wildcard Tester class Create a class with the main method and methods addCat, delete Cat 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 Cat reference to the ArrayList, and prints out a line as shown in the sample output below. deleteCat method Has two parameters, an ArrayList with an upper bound of Cat, and a String with the name of a Cat to be deleted. Deletes the identified Cat reference to the ArrayList, and prints out a line as shown 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 redCats ArrayList. 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 redCat ArrayList. 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on the instructions we need to create a Java program with a few classes demonstrating inheritance and the use of generics with wildcards Lets go ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!