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

Mapa mental

Inheritance

Cody Miller Inglês

Conteúdo do mapa

Inheritance

  1. Extends Keyword

    • adding "extends ParentClass" to the child class declaration will have the child class extend the parent class.
      • Extending a class means saying the child class is a type of the parent class, like saying a bird is an animal, where bird is the child and animal is the parent.
        • Allows the child class to use the methods within the parent class, but can still declare their own methods which the parent and other child classes cannot use.
          • Allows one to declare an object like Animal animal = new Bird(); but not like Bird bird = new Animal();
  2. Accessibility

    • A subclass/child class can access the superclass/parent class's public and protected methods and fields, but not private methods.
  3. method Overriding

    • Writing a method in a child class with the same name and arguments as in the parent class, the program will run the method in the child class.
      • This cannot be done with final methods.
  4. Calling the Superclass's Constructors

    • When using a child class constructor, the parent class's constructor is called, which will label the child object as an instance of the parent type as well.
      • This must be done with a no-argument constructor in the parent class. If there is none, there will be a compiler error.
  5. Calling the Superclass's Hidden Members

    • using the "super" keyword, you can call a hidden member or an overridden method of the super class.
  6. Type Casting

    • You can cast an object of a child class to be an object of the parent class.
      • Can be done by Child child = new Child(); Parent parent = child;
  7. Final Classes

    • declaring "final" before a class will not allow another class to use that one as a parent.
  8. Instanceof Keyword

    • Can be used to test if an object is of a specified type (works with child objects being tested as a parent object).
      • Ex: String s = "Hello"; if(s instnaceof java.lang.String){a=true} will check if the object s is a String, which it is, so will run the inside of the if statement, making a to be true.

Informações

Descrição
Mapa Mental sobre Inheritance, criado por Cody Miller em 21-11-2019.
Criado por
Cody Miller
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?