Inheritance
It is a mechanism that enables one class to inherit
behavior and attributes of another class
It is how applying a general category into specific objects.
Inheritance
It is a visual tool that provides overview of a class
Class diagram
This modeling language consists of various types of diagrams
Unified Modeling Language (UML)
This is used to create derived classes
Inheritance
Importance of Inheritance
This is used as the basis of inheritance
Base class (a.k.a. Parent class, Superclass)
This is a class that derives/inherits from the base class
Derived class (a.k.a. Child class, Subclass)
Always “is a” case or example of more general base
class
Derived class
To achieve inheritance in Java, this keyword is used
extends
This means that the child can only inherit the parent, not the way around
Inheritance as a one-way proposition
This keyword is a checker if an object is derived from a class, a subclass, or an interface.
instanceof
This contains data and methods defined in
original superclass
Subclass
Fact about overriding superclasses
Sometimes superclass data fields and methods not
entirely appropriate for subclass objects
Using same method name to indicate different
implementations
Polymorphism
How to override the parent class using the child class
Create method in child class that has same name
and argument list as method in parent class
Ability of one method name to work appropriately for
different subclass objects of same parent class
Subtype polymorphism
How to instantiate an object that is member of subclass
Call at least two constructors: one in base class, one in derived class
How to access superclass methods ?
Using the “super” keyword