- Polymorphism in java is the ability for an object variable to be assigned as it's value any object that is part of a class that is a child of the variable's class
- One place this is useful is creating methods that can take in many different objects as parameters
- You could imagine a printing method that can print an array of different objects that are passed where maybe not all of those objects are the same.
- Without polymorphism when you tried to assign any non base object to object the program would crash.
- Polymorphism allows this object to hold any of those variables
- This returns "A"
- This returns "~~B~~ A"
- "A A"
- The program will compile successfully
- The program will output 1
- "foo1: b a"
- "Name: fluffy\nSpecies: Canis Familaris(pomeranian)"
- "Name: george\nSpecies: Canis Familaris"
- "Name: brutus\nSpecies: Felis Catus"
-
Unknown
-
Unknown
-
Error will not compile
-
41
-
49
-
y
-
42
-
7
-
Error will not compile
- You can not call abstract classes directly you can only call with super. (you can also make abstract methods
- you should include the basics of a car like the tires steering wheel axels that are shared amongst all cars.