Search⌘ K

Challenge 2: Displaying Message Using Inheritance

Explore how to apply Java classes and inheritance to model animals with properties like name, age, and origin. This lesson guides you through building a parent class and derived classes to generate descriptive messages, helping you understand object-oriented principles in Java.

We'll cover the following...

Problem statement

Whenever you visit a zoo, there are many types of animals in it. However, for each animal some things never change- they all have a name and an age. Also a country of origin. This time, we want you to use the concept of classes and inheritance to solve the exercise below!

Coding exercise

The code below has:

  • A parent class named Animal.

    • Inside it
...