¡GoConqr estrena diseño! Cuéntanos qué te parece.

Mapa mental

Inheritance

Rodolfo Gonzalez Inglés

Contenido del mapa

Inheritance

  1. It is what makes code extensible in any OOP language.

    • You extend a class by making a new class
      • Using the "extends" keyword
        • Ex. Parent and Child Class
      • All Java classes automatically extend the java.lang.Object class
  2. Also called subclassing

    • You can use the "final" keyword" to prevent inheritance
    • Forms an is- a relationship between the subclass and the superclass
  3. Allows you to add functionality that didn't exist in the original class

  4. Accessibility

    • A subclass can access a superclass's public, protected and default methods
      • Cannot access private methods
      • Can also override only these types of methods
        • You override by simply writing a new method in the subclass
          • Don't need to change anything in parent class
    • Call a subclass just like any class with a constructor
      • "super" keyword represents an instance of the direct superclass of the current object
        • Can also be used to call hidden members
  5. Casting

    • Cast an object to another type
      • Can only cast an instance of a subclass to its parent class (called upcasting)
        • Can downcast only if the object had been upcasted previously from that class
  6. "Instanceof" Keyword

    • Used in an if statement to return a boolean
      • True, if the object is an instance of that class
      • False, if object is null or isn't of that class

Información

Descripción
Mapa Mental sobre Inheritance, creado por Rodolfo Gonzalez el 21/11/2019.
Visitas
1
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?