60a17aae57a0d41ba0b52c54 - AP CS A Study Guide Unit 9
60a17aae57a0d41ba0b52c54 - AP CS A Study Guide Unit 9
60a17aae57a0d41ba0b52c54 - AP CS A Study Guide Unit 9
Inheritance
● Example (part 2)
}
return false;
}
}
Super Keyword
● Two uses of the keyword super
o super();
o super(arguments);
o super.method();
▪ Calls the superclass method but not the constructors from the class.
Creating References Using Inheritance Hierarchies
● Inheritance Hierarchy
o Subclass inheriting from a superclass
o Formed with an object
o Objects at the top of the hierarchy
Polymorphism
● Compile Time
o Methods in the declared type
o Determines the accuracy of a non-static call
● Run Time
o Methods in the object type
o Implemented for a non-static call
o Known as polymorphism
Object Superclass
● Object Class is superclass of all classes in Java
o In the built-in java.lang package
● These are two Object class methods and constructors
o String toString()
o boolean equals(Object other)
● Subclasses of Object can override these methods with implementations that are specific
to the class.