Mapa mental
Inheritance
Conteúdo do mapa
Inheritance
It is what makes code extensible in any OOP language. Extending a class is also called inheriting or subclassing.
- You extend a class by creating a new class. The former and the latter will then have a parent-child relationship.
- Inheritance gives you the opportunity to add some functionality that does not exist in the original class.
- The subclass and the superclass has an “is-a” relationship.
- Method overriding occurs when you write in a subclass a method that has the same signature as a method in the parent class.
- When you instantiate a child class by invoking one of its constructors, the first thing the constructor does is call the no-argument constructor of the direct parent class. In the parent class, the constructor also calls the constructor of its direct parent class.
- The super keyword has another purpose in life. It can be used to call a hidden member or an overridden method in a superclass. Since super represents an instance of the direct parent, super. memberName returns the specified member in the parent class.
- You can cast an object to another type. The rule is, you can only cast an instance of a subclass to its parent class. Casting an object to a parent class is called upcasting. Downcasting requires that you write the child type in brackets.
- You can prevent others from extending your class by making it final using the keyword final in the class declaration.Design consideration, and not speed, should be the reason you make a class final.
- The instanceof keyword can be used to test if an object is of a specified type. It is normally used in an if statement.
- Extend a class by using the extends keyboard in the class declaration, after the class name and before the parent class
- From within a subclass you can access its superclass’s public and protected methods and fields, but not the superclass’s private methods.
- Inheritance gives you the opportunity to add some functionality that does not exist in the original class.
- You extend a class by creating a new class. The former and the latter will then have a parent-child relationship.
Kurniawan, Budi. Java 7 : A Comprehensive Tutorial, Brainy Software, 2014. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/ufl/detail.action?docID=3003885.
Informações
- Descrição
- Mapa Mental sobre Inheritance, criado por Cal Brynestad em 21-11-2019.
- Criado por
- Cal Brynestad
- Visualizações
- 0
- Avaliação