Mapa mental
Inheritance
Conteúdo do mapa
Inheritance
process of deriving a new class from an existing one.
Super class cannot access child instance data or methods unless its public.
- Child class CAN access PUBLIC data/methods of parents
- Child class CANNOT access PRIVATE data/methods of parent
- Child class CAN access PUBLIC data/methods of parents
Reserved word: extends
- You can only extend ONE class.
protected: can only be accessed by the child of the parent class
Super: gives access to parent's data/methods
- Called like: super() or super(value)
- **If the first line in the Child's constructor is not a call to the parent class. Java implicitly places a super there. With no params**
- Exception: a chained call to another constructor in same class will automatically defer super to that class.
- super(xxx) --> call to parent class constructor
- super.xxx --> call to parent class instance data
- super.xxx() --> call to parent class method
- super.xxx --> call to parent class instance data
- super(xxx) --> call to parent class constructor
- Exception: a chained call to another constructor in same class will automatically defer super to that class.
- **If the first line in the Child's constructor is not a call to the parent class. Java implicitly places a super there. With no params**
- Called like: super() or super(value)
Overriding:
- When a child class defines a method w/ the same name and signature as the parent. The child version overrides the parents.
- How to implement: @Override before the method
- *Static methods can be inherited but NOT overriden.
- How to implement: @Override before the method
- When a child class defines a method w/ the same name and signature as the parent. The child version overrides the parents.
Informações
- Descrição
- Computer Science Mapa Mental sobre Inheritance, criado por Tate Johnson em 27-04-2021.
- Criado por
- Tate Johnson
- Visualizações
- 2
- Tags
- Avaliação