Mind map
Inheritance
Map content
Inheritance
Hierarchies
- Parent Class: Also known as the super class, gives the child class (sub class) methods and variables.
- Child Class: Also known as the sub class, it takes the methods and variables from the super class. Thanks to polymorphism, can be casted to the super class type. It uses the extends keyword.
Inheriting Fields and Methods
- Sub classes automatically inherit methods and fields. You can not use the same name for a instance variable that is already used in the super class, but you can overwrite a method to fit the sub class better.
Subclass construction
- Created just like a regular class, but uses the extends keyword followed by the
Converting between subclasses and superclasses: Objects of Subclasses can convert to superclasses, but objects of super classes can not be converted to sub classes.
Super(): is used in the constructor of the child class to give the parent class the required parameters
Abstract Classes: Classes that have one or more abstract methods with at least one regular method. When a sub class extends an abstract class, they must write the code for the abstract methods.
Access control
- Public: Available to all classes in the same package
- Private: Available to only the class it is created in, requires accessor method to get.
- Protected: Protected data in an object can be accessed by the methods of the object’s class and all its subclasses.
Super: keyword that can be used to call methods of the superclass
Object Super class: Default extension when creating a class. Methods can be overwritten.
- toString: returns a string of the location in memory
- equals: sees if the two objects have the same location in memory
Information
- Description
- Mind Map on Inheritance, created by John Hair on 03/05/2018.
- Created by
- John Hair · May 2018
- Updated
- May 3, 2018
- Views
- 0
- Rating