Mindmap
Inheritance
Inhalt der Mindmap
Inheritance
Extend
- Done automatically in Java as an Object is the superclass
- Notation:
- Done automatically in Java as an Object is the superclass
The Is-a Relationship
Superclass and subclasses
Accessibility
- P and C: P has three methods, public, protected and one with default class
- The subclass C can access all these classes but a method outside of the subclass cannot access the default class
- P and C: P has three methods, public, protected and one with default class
Method Overriding
- You can change the behavior of a method in a parent class by writing the new method in the subclass. This is possible to do for the public and protected methods. If subclass and superclass are in the same package, then you can also change default access level.
- You can avoid overriding a method by writing final.
- You can change the behavior of a method in a parent class by writing the new method in the subclass. This is possible to do for the public and protected methods. If subclass and superclass are in the same package, then you can also change default access level.
Calling a superclass' no-arg constructor
Calling a superclass' hidden members
- The Pencil class overrides the toString method in Tool. When you run the Pencil class, you get "Generic Tool// I am a Pencil'
Casting
- Upcasting: casting an object to a parent class by assigning the object to a reference variable of the parent class
- Downcasting:casting down an object a class down the inheritance hierarchy. You need to write the object in brackets. Subclass needs to exist in the parent class as a reference or else you get an error
instanceof Keyword: used to test if a object is of a specified type. It is normally used an in if statement.
Bilder und Dateien der Mindmap
Informationen
- Beschreibung
- Mindmap am Inheritance, erstellt von Jeremy Deleon am 06/08/2019.
- Erstellt von
- Jeremy Deleon
- Aufrufe
- 0
- Bewertung