Mind map
Inheritance
Map content
Inheritance
Overview
- An important feature in OOP used to extend a class.
- Use the "extends" keyword after class name and before parent
- Example: public class Child extends Parent{}
- Multiple inheritance is allowed in C++ unlike JAVA.
- Example: public class Child extends Parent{}
- Use the "extends" keyword after class name and before parent
- Parent-Child Relationship between classes.
- The child class can be extendable until you declare it as "final"
- Use "final" keyword to prevent classes from being subclassed or extended.
- The child class can be extendable until you declare it as "final"
- Allows you to change behaviors of an existing class to better suit your needs.
- An important feature in OOP used to extend a class.
"Is-A Relationship"
- A special relationship between the superclass and the subclass.
- Superclass being a big class and the subclasses are the different types of the superclass.
- Must not assign an instance of a subclass to a reference variable of the parent type.
- A subclass inherits all public methods and fields from the superclass.
- A special relationship between the superclass and the subclass.
Accessibilty
- Have access to superclass's public methods and fields.
Method-Overiding
- By extending a class, you change the method's behavior within the parent class.
- Write in the subclass a method that has the same signature as it does in the parent class.
- Method-Overloading
- Only the name is the same, and the list of argument isn't.
- You can not override a final method
Type Casting
- Cast an object to another type
- Only can cast an instance of a subclass to its parent.
- Casting an object to a parent class is called upcasting.
- Cast an object to another type
Information
- Description
- Mind Map on Inheritance, created by Jada Matthews on 21/11/2019.
- Created by
- Jada Matthews
- Views
- 0
- Rating