Create the java source code files for the classes


Assignment:

Create the Java source code files for the classes listed in the inheritance hierarchy displayed . Create a new Java source code file and enter code for the AbstractTest.java test program, as shown. Compile all source code and execute the test program to obtain the output as displayed. 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 a 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

public class AbstractTest
{
public static void main(String[] args)
{
Cat cat = new Cat("Kitty", "Angora");
Robin bird = new Robin("Rockin");

System.out.println("For the cat: ");
System.out.print("This is: "); cat.describe();
System.out.print("Sound: "); cat.sound();
System.out.print("Sleeping: "); cat.sleep();
System.out.print("Moving: "); cat.move();
System.out.println("\n");

System.out.println("For the robin: ");
System.out.print("This is: "); bird.describe();
System.out.print("Sound: "); bird.sound();
System.out.print("Sleeping: "); bird.sleep();
System.out.print("Moving: "); bird.move();
System.out.println("\n");

System.out.println("\nEnd of program.");
}

}

Attachment:- Flow chart and ouptut.rar

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create the java source code files for the classes
Reference No:- TGS01935199

Now Priced at $25 (50% Discount)

Recommended (97%)

Rated (4.9/5)