70 likes | 164 Vues
Learn the principles and methods related to polymorphism in Java, including Object class, ArrayList methods, and essential Object class methods like equals(), getClass(), hashCode(), and toString(). Explore examples and Q&A to grasp the concept fully.
E N D
Polymorphism Page 206-221
Page 206 • Objects • Every class in Java extends class Object • Every class you write extends Object • Any class that doesn’t explicitly extend another class, implicitly extends Object • Page 208 – ArrayList methods -
Page 209 • Class Object – 4 Methods • Boolean equals () • Tells you if two objects are considered equal • Class getClass() • Gives you back the class an object is instantiated from • InthashCode () • Prints out a hashcode for the object • String toString () • Prints out a string message with name of class & a number
Q & A page 210; Example Page 211 • Read through Q&A – page 210 • Examples of using Polymorphic References of type object – • Good example of Array List Dog Objects v. Any type of objects! • Be Careful!!