Hierarchies

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.

Answer:

  • How many types of automobile are there in the diagram?
    • Two — the general type "Automobile" and a specific type, "Ford."
  • How many automobile objects are there in the diagram?
    • Three.

Hierarchies

hierarchy of classes

 

 

This picture shows a hierarchy of classes. It shows that "Ford is-a automobile," "Nissan is-a automobile," and that "VW is-a automobile." It also shows that "Sentra is-a Nissan."

In a hierarchy, each class has at most one parent but might have several children classes. The class at the top of the hierarchy has no parent. This class is called the root of the hierarchy.

QUESTION 7:

Is Nissan a child of Automobile?
Is Nissan the parent of Sentra?