Module 5 - Java Zoo

 Objective

To understand and implement Java inheritance by creating a class hierarchy for animals in a zoo.

Part 1: Base Class Creation

  • Task: Create a base class Animal.

    • Include common attributes (e.g., name, age).

    • Implement methods like eat(), sleep().

Part 2: Creating Subclasses

  • Task: Create at least three subclasses of Animal (e.g., Lion, Elephant, Monkey).

    • Each subclass should have unique attributes or behaviors - this is your choice, you must include at least one.

    • Demonstrate the use of super to access superclass methods and constructors.

Part 4: Overriding Methods

  • Task: Override methods in the subclasses.

    • Example: Overriding the eat() method to reflect each animal's specific diet.

Part 5: Implementing a displayInfo() Method

  • Task: Implement a displayInfo() method in each class to print details about each animal.

Part 6: Main Class and Testing

  • Task: Create a Driver program to instantiate different animals and call their methods.

!  Deliverables

Upload the following files in a zip folder that you have created:

  1. Java class files

  2. Screenshot of the Console with the code executing

 

COSC-1437 / ITSE-2457 Computer Science Dept. - Author: Dr. Kevin Roark