Polymorphism Flashcards
1
Q
What is polymorphism?
A
Refers to classes in which the base and derived classes have the same functions.
Using the same method name to indicate different implementations.
2
Q
What is the process of overriding?
A
This is when the methods that a subclass would normally inherit are redefined.
3
Q
What two rules does the compiler follow if the function exists in both the superclass and the derived class?
A
- If the function is invoked by the object of the subclass, then the function of the subclass is executed.
- If the functions is invoked by the object of the superclass, then the superclass method is executed.
4
Q
What methods cannot be overridden?
A
Private
Static
Final
Methods with final classes
5
Q
What does super() do?
A
Used to call the superclass and access the constructor in the superclass.