Skip to content

Commit ccb83e0

Browse files
committed
Section 11 Object Oriented Programming.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent fdad0be commit ccb83e0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Section11ObjectOrientedProgramming/src/Polymorphism.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
Polymorphism is a core concept in Object-Oriented Programming (OOP) that refers to the ability of a single function,
22
method, or object to behave in multiple ways.
33

4-
The term polymorphism comes from Greek, where "poly" means "many" and "morph" means "form." Essentially,
5-
polymorphism allows different classes to be treated as instances of the same class through inheritance, while allowing
4+
The term polymorphism comes from Greek, where "poly" means "many" and "morph" means "form"
5+
6+
Essentially, polymorphism allows different classes to be treated as instances of the same class through inheritance, while allowing
67
for different behaviors depending on the specific class type that is being referenced.
78

89
Method overloading is an example of compile-time (static) polymorphism in Java.
@@ -14,15 +15,12 @@ The compiler determines which method to call based on the number, types, and ord
1415
This provides flexibility in method invocation and improves code readability.
1516

1617
What is Polymorphism?
17-
1818
Polymorphism is a core concept in Object-Oriented Programming (OOP) that refers to the ability of a single function,
1919
method, or object to behave in multiple ways.
2020

21-
2221
There are two main types of polymorphism:
2322

2423
1. Compile-Time Polymorphism (Static Polymorphism):
25-
2624
Compile-time polymorphism is resolved during the compilation process, before the program runs.
2725

2826
This type of polymorphism is typically achieved through method overloading or operator overloading.
@@ -40,7 +38,10 @@ Often used to improve program efficiency by providing method customization witho
4038

4139
2. Run-Time Polymorphism (Dynamic Polymorphism)
4240

43-
Run-time polymorphism is resolved at runtime, meaning the decision of which method to invoke happens while the program is executing. This is typically achieved through method overriding, where a subclass provides a specific implementation of a method that is already defined in the superclass.
41+
Run-time polymorphism is resolved at runtime, meaning the decision of which method to invoke happens while the program is executing.
42+
43+
This is typically achieved through method overriding, where a subclass provides a specific implementation of a method
44+
that is already defined in the superclass.
4445

4546
Key characteristics:
4647
Occurs at runtime.
@@ -89,4 +90,4 @@ It is achieved through method overriding and is a key feature of object-oriented
8990
providing flexibility and extensibility to the code.
9091

9192
In summary, polymorphism makes it easier to extend and maintain your code while enabling more flexible and dynamic
92-
behavior at runtime.
93+
behavior at runtime.

0 commit comments

Comments
 (0)