Skip to content

Commit 8b9ad4d

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Section11ObjectOrientedProgramming/src/Polymorphism.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ method, or object to behave in multiple ways.
33

44
The term polymorphism comes from Greek, where "poly" means "many" and "morph" means "form"
55

6-
Essentially, polymorphism allows different classes to be treated as instances of the same class through inheritance, while allowing
6+
Essentially, polymorphism allows different classes to be treated as instances of the same class through inheritance,
7+
while allowing
78
for different behaviors depending on the specific class type that is being referenced.
89

910
Method overloading is an example of compile-time (static) polymorphism in Java.
@@ -65,7 +66,9 @@ Real-World Example of Polymorphism:
6566
Think of a vehicle in the real world:
6667
- A Vehicle class could have a method called `move()`.
6768
- Different types of vehicles (Car, Bike, Truck) may override the `move()` method to implement how they move.
68-
- At runtime, if you have a reference to a `Vehicle` object, you might not know whether it is a `Car`, `Bike`, or `Truck`, but when you call `move()`, the correct method for the actual object type will be executed (this is dynamic polymorphism).
69+
- At runtime, if you have a reference to a `Vehicle` object, you might not know whether it is a `Car`, `Bike`, or
70+
`Truck`, but when you call `move()`, the correct method for the actual object type will be executed
71+
(this is dynamic polymorphism).
6972

7073
---
7174

0 commit comments

Comments
 (0)