Mindmap
Inheritance
Inhalt der Mindmap
Inheritance
The process of extending a class in OOP
Gives you the opportunity to add some functionality that does not exist in the original class
Gives the chance to change the behaviors of the existing class to better suit your needs
Extends Keyword
- Used to extend a class
- A class can only extend one class
- Placed in class declaration
Is-a relationship
- Relationship formed when you create a new class by inheritance
- Subclass inherits methods from superclass
- You can assign an instance of a subclass to a reference variable of the parent type
Accessibility
- In a subclass, the superclass's public and protected methods and fields can be accessed
- Protected Method
- Not accessible from outside class except from a subclass
Method Override
- When extending a class, the behavior of the method of the parent method can be changed
- To override, write the new method in the subclass
Calling Superclass constructors
- First thing constructor does is call the no-argument constructor of the direct parent class
- Process repeats until the constructor of the object class is reached
- Super Keyword
- An instance of the direct superclass of the current object
Calling Superclass Hidden Members
- Super Keyword
- Used to call a hidden member or an overridden method in the superclass
- Super Keyword
Type Casting
- Upcasting
- Casting an object to a parent class
- Assign the object to a reference variable of the type Superclass
- Downcasting
- Casting an object to a class down
- Write the child type in brackets
- Upcasting
Final
- Prevents others from extending your class by making it final
instanceof Keyword
- Used to test if an object is of a specified type
Informationen
- Beschreibung
- Mindmap am Inheritance, erstellt von Ivan Mitevski am 21/11/2019.
- Erstellt von
- Ivan Mitevski
- Aufrufe
- 0
- Bewertung