WEBVTT

00:00.000 --> 00:05.000
Why polymorphism matters?

00:05.000 --> 00:13.000
In Java, polymorphism allows one action to behave in different ways, depending on the object that performs it.

00:13.000 --> 00:19.000
It helps programs become flexible, reusable, and easier to extend.

00:19.000 --> 00:26.000
Two main ways Java supports polymorphism are method overloading and method overriding.

00:26.000 --> 00:32.000
Overloading lets us use the same method name with different parameter lists.

00:32.000 --> 00:39.000
For example, a print method may accept a string, an integer, or even an object.

00:39.000 --> 00:42.000
Each version handles the input differently.

00:42.000 --> 00:49.000
Overriding, on the other hand, changes the behavior of a parent class method inside a subclass.

00:50.000 --> 00:56.000
This allows customized behavior for different objects while keeping the same method signature.

00:56.000 --> 01:01.000
Overriding ensures same method name and parameters.

01:01.000 --> 01:05.000
Different implementation in the subclass.

01:05.000 --> 01:08.000
Behavior depends on the actual object.

01:08.000 --> 01:15.000
Polymorphism gives Java programs a cleaner structure, shared behavior patterns, and easier code updates.

01:15.000 --> 01:21.000
This prepares us to explore how dynamic binding works at runtime.

01:21.000 --> 01:25.000
Method overriding versus method overloading.

01:25.000 --> 01:29.000
Method overloading occurs within the same class.

01:29.000 --> 01:34.000
It uses the same method name, but different parameter types or counts.

01:34.000 --> 01:40.000
It helps simplify readability and organize similar tasks under one method name.

01:40.000 --> 01:44.000
Method overriding happens across parent and child classes.

01:44.000 --> 01:50.000
The subclass rewrites a parent method using the same signature but new logic.

01:50.000 --> 01:52.000
Points from the image.

01:52.000 --> 01:57.000
Overriding, same method signature, different implementation.

01:57.000 --> 02:01.000
Overloading, same name, different parameters.

02:01.000 --> 02:07.000
Overriding changes or enhances the behavior of the parent method.

02:07.000 --> 02:11.000
Dynamic binding, late binding.

02:11.000 --> 02:15.000
Dynamic binding is a key pillar of runtime polymorphism.

02:15.000 --> 02:23.000
It decides which version of an overridden method should run only when the program is executing, not during compilation.

02:23.000 --> 02:31.000
This means the method chosen depends on the actual object type, not the reference type.

02:31.000 --> 02:35.000
Points from the image. Run time decision.

02:35.000 --> 02:39.000
Which method gets called depends on the actual objects type.

02:39.000 --> 02:43.000
Demonstrated using a polymorphic array of objects.

02:43.000 --> 02:50.000
Example, imagine an array of type vehicle that stores car, truck, and bike objects.

02:50.000 --> 02:57.000
When we loop through the array and call drive, each object runs its own overridden version of the method,

02:57.000 --> 03:01.000
even though all are stored as vehicle references.

03:01.000 --> 03:07.000
Dynamic binding makes code more reusable and general while allowing each subclass

03:07.000 --> 03:11.000
to express its unique behavior.

03:11.000 --> 03:15.000
Real-world applications plus extensibility.

03:15.000 --> 03:22.000
Polymorphism is widely used in frameworks, libraries, and real-world applications.

03:22.000 --> 03:31.000
For example, a drawing application may have a shape superclass and subclasses like circle, rectangle, and triangle.

03:31.000 --> 03:37.000
The framework only calls draw, but each shape implements it differently.

03:37.000 --> 03:41.000
You can add new shapes without modifying old code.

03:41.000 --> 03:44.000
Another real-world case is file handling.

03:44.000 --> 03:52.000
A file reader, buffered reader, or input stream reader may all override read in their own way.

03:52.000 --> 04:00.000
Polymorphism enables developers to build systems that grow easily, stay organized, and support long-term maintainability.

04:01.000 --> 04:03.000
Conclusion

04:03.000 --> 04:09.000
In this session, we learned how method overloading and overriding differ.

04:09.000 --> 04:14.000
How overriding changes parent behavior using the same method signature.

04:14.000 --> 04:18.000
How dynamic binding selects methods at runtime.

04:18.000 --> 04:23.000
How polymorphism supports extensibility in frameworks.

04:23.000 --> 04:28.000
And how polymorphism helps reduce repeated code and improve design.

04:28.000 --> 04:33.000
Polymorphism through overriding, overloading, and dynamic binding

04:33.000 --> 04:39.000
makes Java applications flexible, scalable, and easier to maintain.

04:39.000 --> 04:48.000
Mastering these ideas prepares students for advanced OOP techniques and real-world software development.

