Picture of a Fleet

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.
go to previous page   go to home page   go to next page

If a Fleet object is constructed, how many new objects will there be?

Answer:

Three — the Fleet object itself and the two Car objects it refers to.

Picture of a Fleet

The picture shows that objects of class Fleet contain two references to Car objects.

picture of a fleet

In these notes, class definitions are shown as clouds and objects are shown as rectangles. (In official UML both are shown as rectangles.)

QUESTION 8:

How (in general) would you calculate the average miles per gallon of a fleet of cars?