C++ & Java are both object-oriented languages, thus the following diagram applies to both.

Inheritance vs Composition Example