WildcardTester (30) Animal class Create a simple class called Animal instantiated with a name and a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
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 the full answer
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Why is an investment portfolio containing a mix of stocks and bonds less risky than one containing a single asset class? Because the markets for stocks and bonds tend to move in the same direction at...
-
Why does the color of sunsets vary from day to day?
-
A steady, incompressible, two-dimensional (in the xy-plane) velocity field is given by Calculate the acceleration at the point (x, y) = (1.55, 2.07). V = (0.523 1.88x + 3.94y)i + (2.44 + 1.26x +...
-
Define a simple machine.
-
The Slattery Company was formed on January 1, 2010 to build a single product. The company issued no-par common stock on that date for $300,000 cash. The product costs $20 to make, all of which is...
-
Fox News won a court case by 'persuasively' arguing that no 'reasonable viewer' takes Tucker Carlson seriously Sonam Sheth Sep 24, 2020, 11:42 PM A federal judge on Thursday dismissed a lawsuit...
-
Orie and Jane, husband and wife, operate a sole proprietorship. They expect their taxable income next year to be $450,000, of which $250,000 is attributed to the sole proprietorship. Orie and Jane...
-
Map a supply chaAs the Sourcing Manager, you need to advice the company to critically evaluate possible options to relocate the manufacturing facility out of China or to find an alternative location...
-
I don t see that in my intermediate accounting text I saved from college, you explain to another member of the accounting division of Dowell Chemical Corporation. This will take some research. Your...
-
2. How does religious ritual provide a sense of purpose for participants? How is power and hierarchy might be involved? How might that manifest itself?
-
The scores for a math test are shown below, ordered from smallest to largest. 60 63 63 67 68 68 69 69 67 71 71 71 72 73 73 73 75 75 79 80 81 82 82 86 87 87 91 93 93 94 Fill out the stem and leaf plot...
-
Modern Electronics Company purchases merchandise inventory from several suppliers. On April 1, 2023, Modern Electronics purchased from Speedy Supplies $120,000 of inventory on account. On May 15,...
-
1) What is Ynamides : Synthesis, Reactivity and Applications in organic chemistry.
-
A deposit of $660 earns interest rates of 8 percent in the first year and 11 percent in the second year. What would be the second year's future value? (Round your answer to 2 decimal places.) Future...
-
What types of questions can be answered by analyzing financial statements?
-
What would be the effect if the code for the reverse method were changed to the following? public static void reverse (Scanner input) { if (input.hasNextLine () ) { // recursive case (nonempty file)...
-
What is one benefit of making the list iterator into an inner class?
-
Write a method called countQuarters that takes an int representing a number of cents as a parameter and returns the number of quarter coins represented by that many cents. Dont count any whole...
-
Thor Industries manufactures Airstream and other recreational vehicles (RVs). In In June 2023, an article in the Wall Street Journal stated that the inventories of RVs held by Thor dealers had risen...
-
An article in the New York Times in early 2009 stated that even though The the U.S. economy was in a recession, and movie ticket sales had increased by 17.5 percent. In contrast, during 2020, ticket...
-
An article on barrons.com observed that the U.S. dollar has been droppingand thats good news for the stock market and companies that get a large chunk of their sales from overseas. a. What does the...
Study smarter with the SolutionInn App