Home

supertype

A supertype is a term used in type theory, object-oriented programming, and data modeling to describe a type that serves as a common ancestor for more specific types, called subtypes. A supertype defines the attributes and operations shared by its subtypes. Any value that belongs to a subtype is also a valid value of the supertype, a property known as subtyping or upcasting. The reverse operation, downcasting, may require runtime checks and can fail if the value does not actually conform to the subtype.

In programming languages, supertypes include classes and interfaces. Examples: Object is the universal supertype of all

In data modeling and conceptual design, supertypes model generalization: a supertype holds common attributes such as

Implementation and design considerations include choosing when to use a supertype, ensuring the common interface is

classes
in
Java;
Number
is
a
supertype
of
Integer
and
Double;
an
Animal
supertype
might
organize
subtypes
such
as
Cat
and
Dog.
Generics
and
polymorphism
rely
on
supertype
relationships
to
allow
generic
code
to
operate
on
any
subtype.
identifiers
and
shared
relationships,
while
subtypes
add
specialized
attributes.
Subtypes
can
be
disjoint
or
overlapping:
disjoint
means
an
instance
belongs
to
at
most
one
subtype,
while
overlapping
allows
multiple
subtypes
to
apply
to
the
same
instance.
meaningful,
and
balancing
reuse
with
maintainability.
The
approach
supports
polymorphism
and
code
reuse
but
can
introduce
complexity
if
subtypes
diverge
or
conflict
in
behavior.