Mapa mental
Inheritance
Conteúdo do mapa
Inheritance
extending a class
- creating a new class
- child class/subclass of parent
- opportunity to add functionality that does not exist in original
- change behavior of existing class
- opportunity to add functionality that does not exist in original
- child class/subclass of parent
- creating a new class
Extends Keyword
- all java classes automatically extend the java.lang.Object class
- Object = superclass
- parent, by default is a subclass of Object
- Object = superclass
- all java classes automatically extend the java.lang.Object class
Relationship
- example: bird, fish, dog are all subclasses of animal
Accessibility
- within subclass, access superclass and protected methods and fields
- cannot access superclass's private methods from subclass
- within subclass, access superclass and protected methods and fields
Method Overriding
- override method to change behavior
- override by writing new method in subclass
- don't have to change anything in parent class
- override by writing new method in subclass
- override method to change behavior
Calling Superclass's constructors
- Implicit calling to the parent's constructor that does not exist
- compile error
- compiler adds an implicit call to no argument constructor in Parent
- compile error
- Implicit calling to the parent's constructor that does not exist
Calling the superclass's Hidden Members
- using super to access hidden member
Type Casting
- FInal classes
Informações
- Descrição
- Mapa Mental sobre Inheritance, criado por Joyce Xie em 21-11-2019.
- Criado por
- Joyce Xie
- Visualizações
- 0
- Avaliação