Polymorphism

Binding: Which method is being executed is defininded as bincineo———————————————————————————————————————

Binding: Conneting soem call to a method to a particular definition.


Static Binding: The type of object is determined a coupile times.


Dynamic Binding: The type of object is detemermined during run time.


Static binding is determined at compile time, and if static, final, or private is used in a method, then it will take place.

(method overloading is an example)


Example:


Dynamic(LAte) Binding

The type of object determined at run time, like inheritnce. Object reference, where complies cant know whihcd



Slow and Dynamic Bining



DownCasting)


Okay, with these two, the relationship between a parent and child class, and specifically, what methods they have access to, depends on how you cast it. Remeber the rectangles, square thing, so you basically hav eto cast it, even when it is a car, when going up, trying to use it.


Really for specific methods that has methods for the object class, espeically for trying to access different overridden methods. So instead of the your child class overriden method, it will check the parents code.


Yeah, the parent can’t be considered a part of the child class, so calling their methods isn’t easy, so you would have to cast ti, for it to work.




Also, when ti comes to sending the casted object as a parameter, if that method calls another method, and it has a overriden method, it will call that overriden method, since it is calling from the object type, not the casting time.




Polymorphism with Interfaces



Why Upscaling in practice.


IF you only use the overriden methods of a superclass, for clode flexibiity, upcasting might be nice.



Casting marrlist to arraylist less, instead of the regular one, so that you can print and modify it.

The list/modifiers of Interface



Can’t cast Arraylists to arrays, and vise versa.





When it comes to casting, if you make the parameter you are sending to too generic, and sending in somethign that doesn’t work, like sending a String as an object, you can’t just modify it with cat and try