Create an abstract base class animal the single constructor


Assignment

Using Abstract Classes and Methods Create the Java source code files for the classes listed in the inheritance hierarchy displayed in Figure 10-60a. Create a new Java source code file and enter code for the AbstractTest.java test program, as shown in Figure 10-60b. Compile all source code and execute the test program to obtain the output as displayed in Figure 10-60c. Perform the following steps to complete these tasks:

1. Create an abstract base class, Animal. The single constructor requires a String to indicate the type of animal, which then is stored in an instance variable.

2. Create a concrete class, Cat, which inherits from Animal. Cat has two instance variables, both Strings: name, which has private access and breed, which has protected access.

3. Create an abstract class, Bird, which inherits from Animal. Bird has a single instance variable, breed, of type String with protected access. Bird implements only the required move() method.

4. Create a concrete class, Robin, which inherits from Bird. Robin has a single instance variable, name, of type String with private access. Robin implements the remaining required methods.

5. Compile all source code and execute the test program to obtain the output as displayed in Figure 10-60c.

6. Create a Dog class and a Fish class, both inheriting from Animal.

7. Re-write Abstract Test (Figure 10-60b) as LoopTest.java. Create an arrray of Animal and then loop through the array using an enhanced for(), calling the describe(), sound(), sleep(), and move() methods, successively. Save and then print your source code.

8 Change LoopTest.java to use an Array List instead of an array. Print your source code and indicate whether or not your for() loop had to be modified when changing from an array to an Array List.

580_Figure 10-60a.jpg

2100_Figure 10-60b.jpg

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Create an abstract base class animal the single constructor
Reference No:- TGS02732561

Expected delivery within 24 Hours