Mapa mental
Chapter 6
Conteúdo do mapa
Chapter 6
INHERITANCE
- Inheritance is what makes code extensible in any OOP language
- The process of extending a class
- extend a class by using the "extends" keyword in class declaration
- extending a class is known as inheriting / subclassing
- use the "final" keyword to prevent classes from being subclassed
- extend a class by creating a new class
- "new" keyword creates an instance of a subclass
- keyword "super" represents an instance of the direct superclass of the current object
- you can explicitly call the parents constructor from a subclass’s constructor with super keyword, super must be first statement in the constructor
- super can call a hidden member or an overridden method in a superclass
- "instanceof" keyword used to test if an object is of a specified type typically used in an if statement
- keyword "super" represents an instance of the direct superclass of the current object
- "new" keyword creates an instance of a subclass
- subclass inherits all public methods and fields of its superclass
- you can access a superclass public and protected methods and fields within the subclass, but you cannot access the private methods
- method overriding - changing the behavior of a method in the parent class by writing in a subclass a method with the same signature as a method in the superclass
- method overloading - only the name is the same but the list of arguments is not
- “is-a” relationship is when you create a new class by inheritance
- Gives you the opportunity to add functionality that does not exist in the original class
- gives you the chance to change the behaviors of the existing class to better suit your needs
Informações
- Descrição
- Mapa Mental sobre Chapter 6, criado por Ralph Eubanks em 26-11-2019.
- Criado por
- Ralph Eubanks
- Visualizações
- 0
- Avaliação