Quiz #2 review Flashcards
What are the three types of relationships that can exist between object?
Inheritance, Containment, and Polymorphism
Inheritance definition
“inheriting” code from an already created class. Allows user to add on features to starting classes
Which = “is-a” relationship
Inheritance; sailboat is a boat
Containment definition
“has-a” relationship; car has-a engine
Base Class vs Derived Class
Base class is the starting class while the derived class inherits from the base class
Object superclass properties
cannot be inherited from
Object superclass methods
Equals, clone, toString
overriding definition
child class has the same method as the parent class
overloading definition
When a class contains two methods with the same name, but one has constructors while the other acts as the no-args constructor
Be able to set up the constructor for a derived class and use the super keyword
Be able to set up the constructor for a derived class and use the super keyword
Be able to draw an inheritance hierarchy diagram
Be able to draw an inheritance hierarchy diagram
How do you add inheritance or containment to a class?
Class extends subclass
Differences between private, protected, public, and no access
private can only be accessed by the class, protected can be accessed by the parent class and child classes, public can be accessed by anyone, and no access means nothing has access. No modifier means any file in the current directory may access
private
can only be accessed by the class its contained in
protected
can only be accessed by the parent class and any child classes