GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Mindmap

Inheritance

Rodolfo Gonzalez Englisch

Inhalt der Mindmap

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

Informationen

Beschreibung
Mindmap am Inheritance, erstellt von Rodolfo Gonzalez am 21/11/2019.
Erstellt von
Rodolfo Gonzalez
Aufrufe
1
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck