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

Mapa mental

Inheritance

Todd Bertsch Inglés

Contenido del mapa

Inheritance

  1. Inheritance is a very important feature of object-oriented programming (OOP). It is what makes code extensible in any OOP language. Extending a class is also called inheriting or subclassing.

  2. Java- in java all classes are extendable by default

    • You cannot not extend a class that has been "final"
      • Keywords
        • instanceof
          • The instanceof keyword can be used to test if an object is of a specified type. It is normally used in an if statement and its syntax is. if ( objectReference instanceof type )
    • Ex. public class Child extend Parent
  3. The is-a relationship-There is a special relationship that is formed when you create a new class by inheritance. The subclass and the superclass has an “is-a” relationship.

    • A subclass inherits all public methods and fields of its superclass.
  4. Accessibility

    • From within a subclass you can access its superclass’s public and protected methods and fields, but not the superclass’s private methods. If the subclass and the superclass are in the same package, you can also access the superclass’s default methods and fields.
  5. Method Overriding

    • When you extends a class, you can change the behavior of a method in the parent class. when you write in a subclass a method that has the same signature as a method in the parent class. If only the name is the same but the list of arguments is not, then it is method overloading.
    • You cannot override a final method. To make a method final, use the final keyword in the method declaration.
  6. Type-Casting

    • Upcasting
      • 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
      • you are casting an object to a class down the inheritance hierarchy.

Información

Descripción
Mapa Mental sobre Inheritance, creado por Todd Bertsch el 21/11/2019.
Creado por
Todd Bertsch · nov 2019
Actualizado
21 nov 2019
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?