Inheritance

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

20 Terms

1
New cards
Inheritance

mechanism for code reusability in object-oriented programming

2
New cards

Inheritance

relationship between related types/classes in a superclass–subclass hierarchy.

3
New cards

is-a, has-a

relationships in inheritance

4
New cards

Inheritance

Derived classes (subclasses) are created from base classes (superclasses).
5
New cards

Is-a relationship

Shape (superclass) → Circle, Rectangle (subclasses).
6
New cards

share attributes and behaviors

Objects in two or more classes may ___, but also have unique ones.

7
New cards
Substitution principle
Every circle is a shape. Every rectangle is a shape. Not every shape is a circle/rectangle.
8
New cards

public, protected

subclasses can inherit only features with these access modifier

9
New cards
Superclass constructor

superclasses may define constructors; subclasses can invoke them

10
New cards

Extends keyword

indicates that a subclass inherits from a superclass

11
New cards
Protected modifier

feature is accessible to:

  • its own class,

  • classes in the same package, and to

  • subclasses (even outside the package)

12
New cards

Super keyword

used within a subclass to refer to its superclass; can invoke its constructor, call its method, or access superclass attribute

13
New cards

multiple inheritance, single inheritance

Kinds of Inheritance

14
New cards
Multiple inheritance

subclass derived from more than one superclass

EX. A child can come from two parents

  • Complicated to implement; used in C++

15
New cards
Single inheritance
  • Subclass derived from only one superclass

  • Simple subtyping scheme

16
New cards

ultimate cosmic object class

all Java classes descend from this

17
New cards

Protected

Allows features to be inherited by subclasses even outside the same package.
18
New cards

subclass

Always call the superclass constructor in a ___

19
New cards
Method overriding
Subclass provides a specific implementation of a method from its superclass.
20
New cards

return type, method signature

In method overriding, ___ and ___ (name, parameter types) must be the same as the original method