O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

Inheritence

Maggie Tieu Inglês

Conteúdo do mapa

Inheritence

  1. Extending a class

    • Add "extends" after the class name and before the parent class
  2. The is-a Relationship

    • The special relationship between a sub class and the super class
    • i.e. Animal & Bird, Fish, Dog
    • A subclass inherits all public methods & fields of its superclass (not private ones)
  3. Accessibility

    • From within a subclass, you can access the superclass's public & protected methods/fields (but not private ones)
    • You can only reduce (not increase) visibility in the superclass from the subclass
  4. Method Overriding

    • You can change the behavior of a method in the superclass within the subclass
    • Override a (non-final) method to change its behavior
    • No need to change anything in the Parent class
    • Simply write the new method in the subclass
  5. Calling the Superclass's Constructors

    • Just like an ordinary class, use the "new" keyword to create an instance of it
    • Use "super" keyword to represent an instance of the direct superclass of the current object
      • Can be used to explicitly call the parent's constructor from a subclass's constructor
        • super must be the first statement in the constructor
  6. Calling the Superclass's Hidden Members

    • The "super" keyword can be used to call a hidden member or an overridden method in a superclass
  7. Type Casting

    • You can only cast an instance of a subclass to its parent class
    • Upcasting - casting an object to a parent class
  8. The instanceof Keyword

    • Used to test if an object is of a specified type
    • normally used in an if statement

Informações

Descrição
Mapa Mental sobre Inheritence, criado por Maggie Tieu em 21-11-2019.
Criado por
Maggie Tieu
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?