2.4.12

Polymorphism

Test yourself

Polymorphism

In object-oriented programming, polymorphism is when a subclass alters its inherited methods in two ways: by overloading or overriding.

Illustrative background for OverloadingIllustrative background for Overloading ?? "content

Overloading

  • Overloading is when a method is defined in the subclass that has the same name, but different arguments to a method defined in the superclass.
  • The method might also have a different return type.
  • For example, a shape superclass might have an area calculating function.
    • The subclass circle could have the function area(radius), whereas a triangle subclass could have the function area(base,height).
Illustrative background for OverridingIllustrative background for Overriding ?? "content

Overriding

  • Overriding is when a method is redefined in the subclass with the same name and same arguments.
  • The method that is defined in the subclass overrides the method defined in the super class.

Jump to other topics

1Components of a Computer

2Software & Software Development

3Exchanging Data

4Data Types, Data Structures & Algorithms

5Legal, Moral, Cultural & Ethical Issues

6Elements of Computational Thinking

6.1Thinking Abstractly

6.2Thinking Ahead

6.3Thinking Procedurally

6.4Thinking Logically

6.5Thinking Concurrently

7Problem Solving & Programming

8Algorithms

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium