1/19
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
mechanism for code reusability in object-oriented programming
Inheritance
relationship between related types/classes in a superclass–subclass hierarchy.
is-a, has-a
relationships in inheritance
Inheritance
Is-a relationship
share attributes and behaviors
Objects in two or more classes may ___, but also have unique ones.
public, protected
subclasses can inherit only features with these access modifier
superclasses may define constructors; subclasses can invoke them
Extends
keyword
indicates that a subclass inherits from a superclass
feature is accessible to:
its own class,
classes in the same package, and to
subclasses (even outside the package)
Super
keyword
used within a subclass to refer to its superclass; can invoke its constructor, call its method, or access superclass attribute
multiple inheritance, single inheritance
Kinds of Inheritance
subclass derived from more than one superclass
EX. A child can come from two parents
Complicated to implement; used in C++
Subclass derived from only one superclass
Simple subtyping scheme
ultimate cosmic object class
all Java classes descend from this
Protected
subclass
Always call the superclass constructor in a ___
return type, method signature
In method overriding, ___ and ___ (name, parameter types) must be the same as the original method