Polymorphism Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is POLYMORPHISM?

A

Polymorphism means many forms. It
means that two methods can have the same name but
different contents/functions.

Methods (behaviours) have the same name but
different parameter lists and processes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two types of polymorphism?

A
  1. Overloading (same class)
  2. Overriding (difference classes/inheritance)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the ADVANTAGES of OVERLOADING?

A
  1. We don’t have to create and remember different names for functions doing the same thing.
  2. For example,, if overloading was not supported by Java, we would have to create method names like sum1, sum2,… or sum2Int, sum3Int, … etc. for every possible combination of parameters that might be used.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the ADVANTAGES of OVERRIDING?

A
  1. Polymorphism is essential to object-oriented programming
    for one reason: it allows a general class to specify methods
    that will be common to all of its derivatives, while allowing
    sub classes to define the specific implementation of some or
    all of those methods.
  2. Overridden methods are another way that Java implements
    the “one interface, multiple methods” aspect of
    polymorphism
  3. Overridden methods allow us to call methods of any of the
    derived classes without even knowing the type of derived
    class object.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly