Match the following:
|
|
List I |
|
List II |
|
I) |
Compile-time polymorphism |
A) |
Function overriding |
|
II) |
Run-time polymorphism |
B) |
Access modifier |
|
III) |
Protected |
C) |
Function overloading |
- The Best example of Run time polymorphism is Function Overriding
- Function Overloading is the example of Compile time polymorphism
- Protected is an Access modifier
Important Point
Compile-time polymorphism
It means binding is occurring at compile time It can be achieved through static binding. If a class has multiple methods having the same name but different in parameters, it is known as Method Overloading.
Run time polymorphism
At run time we came to know which method is going to invoke It can be achieved through dynamic binding. If subclass (child class) has the same method as declared in the parent class, it is known as method overriding
Access Modifiers
It specifies the accessibility or scope of a field, method, constructor, or class. There are three types of Access modifiers
- Public: The methods or data members that are declared as public can be accessed anywhere in the program.
- Private: The methods or data members declared as private are accessible only within the class in which they are declared.
- Protected: The methods or data members declared as protected can accessible within the same class or class which is inherited from it.




