Are they interchangeable terms? Would you be able to give formal definitions and also examples?
Both terms (superclass and supertype) are related, but they are not exactly interchangeable.
Only classes have superclasses, while other classifiers have supertypes. Since Class is also a Classifier, a superclass is always a supertype (because superclass redefines the general association between classifiers), but the opposite is not true.
For instance, the primitive type long
in Java is defined as a supertype of int
. Since primitive types are not classes, long
is not a superclass of int
.
Another example: in UML, components and interfaces are different from classes (all of them are classifiers), then it is not correct to say "the superclass of a component" but "the supertype of a component".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With