00:01
Hello student, polymorphism is indeed a fundamental concept in the object oriented programming so shortly we say oops where the same message or the method can have different implementation in different object or the classes.
00:13
So this is the main concept of the polymorphism.
00:16
Why polymorphism is a powerful and a useful feature.
00:19
So it can sometimes lead to the unexpected result or the behavior and if not managed carefully.
00:25
So here are the few examples where polymorphism can lead to unexpected result.
00:32
Method overriding with the unintended consequences.
00:36
Inheritance allows the subclasses to override methods of their parent class.
00:41
If the subclass override a method with a different implementation, it can lead to the unexpected result if the programmer is not aware of the changes.
00:49
For example, if the subclass of the bank account class overrides the withdraw method to impose additional fees, it might surprise users of the base class who expect the same behavior.
01:02
So this can lead to a problem in the subclasses.
01:05
So here polymorphism can create a problem.
01:09
Number two operator overloading.
01:11
Operator overloading allows to define how operators like plus minus multiplications etc.
01:18
Behaves for the custom classes.
01:20
While this is a powerful, it can lead to the unexpected behavior if not used carefully.
01:26
For instance, overloading the plus operator for a custom string class might lead to the unexpected concatenation if not handled correctly.
01:36
So typecasting and polymorphism.
01:38
Polymorphism often involves the typecasting such as downcasting objects to their specific subclass...