Mindmap
Inheritance

Inhalt der Mindmap
Inheritance
The process of extending a class
The child classes inherit all of the methods and fields of the parent class. The child classes can also have new methods and fields as well as the ability to override existing methods from the parent class.
- Child classes can also be extended to become the "parent" class to another class
- For a child class to inherit the methods and fields of the parent class, it should be declared using the extends keyword
- When a class is created by inheritance, the superclass and subclass class have a "is-a" relationship
- In this example: A Rectangle (Subclass) "is-a" Shape (Superclass) and a Triangle (Subclass) "is-a" Shape (Superclass)
- Method Overriding
- A subclass can override a method from its superclass by having a method of the same name and parameters within it
- Method Overloading
- A subclass can overload a method from its superclass by having a method of the same name and different within it
- When a class is created by inheritance, the superclass and subclass class have a "is-a" relationship
- public class Parent{ }
- public class Child1 extends Parent { }
- public class Child2 extends Parent { }
- This can be achieved using interfaces since a class can only extend one class in Java
- For a child class to inherit the methods and fields of the parent class, it should be declared using the extends keyword
- A class can be declared as final if you no longer want it to be extendible or inherited by a subclass
- Child classes can also be extended to become the "parent" class to another class
Bilder und Dateien der Mindmap
Informationen
- Beschreibung
- Mindmap am Inheritance, erstellt von Alyssa M. am 21/11/2019.
- Erstellt von
- Alyssa M.
- Aufrufe
- 0
- Bewertung
