Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Polymorphic Zoo (Java)

A small Java program demonstrating polymorphism and method overloading using a zoo scenario.

Features

  • Animal (abstract) in package zoo with:
    • protected String name
    • abstract makeSound()
    • overloaded concrete makeSound(int times) (repeats the polymorphic sound)
    • concrete getName()
  • Subclasses: Lion, Elephant, Monkey each override makeSound().
  • ZooDemo main:
    • Instantiates animals
    • Stores them in List<Animal>
    • Calls both makeSound() and makeSound(int)

Build & Run

javac -d out $(find src -name "*.java")
java -cp out zoo.ZooDemo

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages