Polymorphism Flashcards

1
Q

What is Polymorphism

A

The concept that objects of different types can be accessed through the same interface.
Each type can provide its own, independent implementation of this interface.

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

Static or Compile Time Polymorphism

A

Method Overloading

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

Runtime Polymorphism

A

Method Overriding

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

Method Overloading Parameter Differences

A

Need to differ in at least one of these ways

  1. Different NUMBER of parameters
  2. Different TYPE of parameters
  3. (NOT RECOMMENDED; lacks readability) Different ORDER of parameter type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Method Signature

A

Different set of parameters for overloaded methods. Allows compiler to identify which method has to be called and to bind it to the method call.

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

Method Signature

A

Different set of parameters for overloaded methods. Allows compiler to identify which method has to be called and to bind it to the method call.

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

Method Overriding

A

A subclass can override a method of its superclass.

Both methods, implemented by the super- and subclass, share the same name and parameters but provide different functionality.

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

Super Keyword

A

It is used to call superclass methods, and to access the superclass constructor. The most common use of the super keyword is to eliminate the confusion between superclasses and subclasses that have methods with the same name.

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

Late Binding

A

Runtime determination of which class should be referenced by which method.

When a subclass object is instantiated and assigned to ta superclass variable, it is still a subclass object. 
Only the superclass methods can be used, but any overridden methods will be called as from the subclass.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

3 General Scenarios of Late Binding

A
  1. The object is of the superclass type and is referenced as a superclass type.
  2. The object is of the subclass type and is referenced as a subclass type.
  3. The object is of the subclass type and is referenced as the superclass type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly