World Library  
Flag as Inappropriate
Email this Article


In knowledge representation, object-oriented programming and design (see object oriented program architecture), is-a (is_a or is a) is a subsumption[1][2] relationship between abstractions (e.g. types, classes), where one Class (computer programming) A is a subclass of another class B (and so B is a superclass of A). In other words, type A is a subtype of type B when A’s specification implies B’s specification. That is, any object (or class) that satisfies A’s specification also satisfies B’s specification, because B’s specification is weaker.[3]

The is-a relationship is to be contrasted with the has-a (has_a or has a) relationship between types (classes).

It may also be contrasted with the instance-of relationship between objects (instances) and types (classes): see "type-token distinction" and "type-token relations."[4] When designing a model (e.g., a computer program) of the real-world relationship between an object and its subordinate, a common error is confusing the relations has-a and is-a.

To summarize the relations, we have

  • hypernym-hyponym (supertype-subtype) relations between types (classes) defining a taxonomic hierarchy, where
    • for a subsumption relation: a hyponym (subtype, subclass) has a type-of (is-a) relationship with its hypernym (supertype, superclass);
  • holonym-meronym (whole/entity/container-part/constituent/member) relations between types (classes) defining a possessive hierarchy, where
    • for an aggregation (i.e. without ownership) relation:
      • a holonym (whole) has a has-a relationship with its meronym (part),
    • for a composition (i.e. with ownership) relation:
      • a meronym (constituent) has a part-of relationship with its holonym (entity),
    • for a containment[5] relation:
  • concept-object (type-token) relations between types (classes) and objects (instances), where
    • a token (object) has an instance-of relationship with its type (class).


  • Examples of subtyping 1
    • C++ 1.1
    • Python 1.2
    • Java 1.3
  • Liskov substitution principle 2
  • See also 3
  • Notes 4
  • References 5

Examples of subtyping

Subtyping enables a given type to be substituted for another type or abstraction. Subtyping is said to establish an is-a relationship between the subtype and some existing abstraction, either implicitly or explicitly, depending on language support. The relationship can be expressed explicitly via inheritance in languages that support inheritance as a subtyping mechanism.


The following C++ code establishes an explicit inheritance relationship between classes B and A, where B is both a subclass and a subtype of A, and can be used as an A wherever a B is specified (via a reference, a pointer or the object itself).

class A 
{ public:
   void DoSomethingALike() const {}

class B : public A 
{ public:
   void DoSomethingBLike() const {}

void UseAnA(A const& some_A)

void SomeFunc()
   B b;
   UseAnA(b); // b can be substituted for an A.


The following python code establishes an explicit inheritance relationship between classes B and A, where B is both a subclass and a subtype of A, and can be used as an A wherever a B is required.

class A:
    def doSomethingALike(self):

class B(A):
    def doSomethingBLike(self):

def useAnA(some_A):

def someFunc():
   b = B();
   useAnA(b)  # b can be substituted for an A.

The following example, type(a) is a "regular" type, and type(type(a)) is a metatype. While as distributed all types have the same metatype (PyType_Type, which is also its own metatype), this is not a requirement. The type of classic classes, known as types.ClassType, can also be considered a distinct metatype.[7]

>>> a = 0
>>> type(a)

>>> type(type(a))

>>> type(type(type(a)))

>>> type(type(type(type(a))))


In Java, is-a relation between the type parameters of one class or interface and the type parameters of another are determined by the extends and implements clauses.

Using the Collections classes, ArrayList implements List, and List extends Collection. So ArrayList is a subtype of List, which is a subtype of Collection. The subtyping relationship is preserved between the types automatically. When we define an interface, PayloadList, that associates an optional value of generic type P with each element. Its declaration might look like:

interface PayloadList extends List {
  void setPayload(int index, P val);

The following parameterizations of PayloadList are subtypes of List:


Liskov substitution principle

Liskov substitution principle explains a property, "If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T,".[8] Following example shows a violation of LSP.

void DrawShape(const Shape& s)
if (typeid(s) == typeid(Square))
else if (typeid(s) == typeid(Circle))

Obviously, the DrawShape function is badly formatted. It has to know about every derivative classes of Shape class. Also, it should be changed whenever new subclass of Shape are created. In Object Oriented Design, many view the structure of this as anathema.

Here is a more subtle example of violation of LSP

class Rectangle
void   SetWidth(double w)  {itsWidth=w;}
void   SetHeight(double h) {itsHeight=h;}
double GetHeight() const   {return itsHeight;}
double GetWidth() const    {return itsWidth;}
double itsWidth;
double itsHeight;

This works well but when it comes to Square class, which inherits Rectangle class, it violates LSP even though the is-a relationship holds between Rectangle and Square. Because square is rectangular. The following example overrides two functions, Setwidth and SetHeight, to fix the problem. But fixing the code implies that the design is faulty.

public class Square : Rectangle
virtual void SetWidth(double w);
virtual void SetHeight(double h);
void Square::SetWidth(double w)
void Square::SetHeight(double h)

The following example, function g just works for Rectangle class but not for Square, and so the open-closed principle has been violated.

void g(Rectangle& r)
assert(r.GetWidth() * r.GetHeight()) == 20);


See also


  1. ^
  2. ^ See Liskov substitution principle.
  3. ^ "Subtypes and Subclasses" (PDF). MIT OCW. Retrieved 2 October 2012. 
  4. ^ Type–token relations
  5. ^ See also Containment (computer programming).
  6. ^  
  7. ^ Guido van Rossum. "Subtyping Built-in Types". Retrieved 2 October 2012. 
  8. ^ Liskov, Barbara (May 1988). Data Abstraction and Hierarchy. SIGPLAN Notices. 
  9. ^ "The Liskov Substitution Principle" (PDF). Robert C. Martin, 1996. Retrieved 2 October 2012. 


  • Ronald J. Brachman; What IS-A is and isn't. An Analysis of Taxonomic Links in Semantic Networks. IEEE Computer, 16 (10); October 1983
  • Jean-Luc Hainaut, Jean-Marc Hick, Vincent Englebert, Jean Henrard, Didier Roland: Understanding Implementations of IS-A Relations. ER 1996: 42-57
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from World eBook Library are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.