Mapa mental
Inheritance
Conteúdo do mapa
Inheritance
Code Extensibility
- extends keyword; Java only allows 1 extension per class
- Create new class; subclass
- Parent-child relationship
- Method Override
- Write method with same signature as parent class method
- Change existing method behaviors
- Write method with same signature as parent class method
- Child has "is-a" relationship to Parent
- Child inherits all public methods of Parent
- Allows reference variable of parent type in assignment of a subclass instance
- Subclass can access public and protected just not private methods from superclass
- Allows reference variable of parent type in assignment of a subclass instance
- Child inherits all public methods of Parent
- Method Override
- keyword new to create an instance
- When subclass object is instantiated, so are all parent's classes
- Parent-child relationship
- Ex: public class Child extends Parent {}
- Create new class; subclass
- final keyword
- Prevent method override; no change in behavior allowed
- Does not permit Method Override
- Speed improvement but design should be main concern
- Ex: public final class Pencil{}
- java.lang.Object
- Ultimate Java superclass
- keyword super represents instance of direct superclass of current object
- Invoke superclass constructor
- Call a hidden member or an overriden superclass method
- Type Casting
- Possible only to cast subclass instance to parent class; "Upcasting"
- "Downcasting" if parent instance is cast as child class
- Possible only to cast subclass instance to parent class; "Upcasting"
- instanceof keyword
- test if object is of specified type; ex: if it's type of its superclass
- extends keyword; Java only allows 1 extension per class
Informações
- Descrição
- Mapa Mental sobre Inheritance, criado por Ana Ausek em 03-08-2019.
- Criado por
- Ana Ausek
- Visualizações
- 0
- Avaliação