Free Online Flashcard Deck

4 Inheritance and Class Hierarchies Free Online FlashCards

Study 4 Inheritance and Class Hierarchies with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is inheritance in object-oriented programming?

Back

Inheritance lets one class acquire selected state and behavior from another class, while also allowing the new class to add or replace members.

02
Front

What are the two classes in an inheritance relationship called?

Back

The existing class is the superclass, base class, or parent class; the new class is the subclass, derived class, or child class.

03
Front

What does an “is-a” relationship mean?

Back

An is-a relationship means the subclass represents a specialized form of the superclass, such as a Dog being an Animal.

04
Front

How can inheritance form a class hierarchy?

Back

A subclass can normally have one direct superclass, while a superclass can have many subclasses. Inheritance can also form a chain such as Animal → Mammal → Dog.

05
Front

Are constructors generally inherited?

Back

Constructors are generally not inherited, although a subclass can invoke a superclass constructor.

06
Front

How does inheritance support reuse through extension?

Back

A subclass reuses common superclass code and adds features that distinguish the specialized type, reducing duplication and centralizing shared behavior.

07
Front

What is the purpose of an abstract superclass?

Back

An abstract superclass represents a meaningful general concept, provides shared implementation, and may require subclasses to implement essential operations.

08
Front

What is method overriding?

Back

Overriding occurs when a subclass supplies a new implementation with the same method signature as an inherited overridable method.

09
Front

What does Java’s @Override annotation provide?

Back

In Java, @Override documents the programmer’s intent and lets the compiler detect mistakes such as an incorrectly spelled method name.

10
Front

How can an override reuse the superclass implementation?

Back

A subclass can call the superclass implementation with super in Java or base in C# before adding its own behavior.

11
Front

What does polymorphism enable?

Back

Polymorphism lets code use a superclass reference while the runtime selects the overridden method belonging to the object’s actual subclass.

12
Front

When is inheritance a good design choice?

Back

Use inheritance when the subclass is genuinely specialized, the superclass behavior fits every subclass, and subclasses can honor its expectations.