GoConqr has a new look! Let us know what you think.

Mind map

Inheritance

Jeff Golub English

Map content

Inheritance

  1. We can create a new class by extending an existing one

    • Orginial = parent class or superclass
    • New = child class or subclass
    • Any class can be extended unless declared as "Final"
    • With "extends" keyword
    • A class can only extend one class
  2. A subclass inherits all public fields and methods of the superclass

    • A subclass can also access all the superclass' protected methods/fields
      • A protected method is not accessible outside of the class except by a subclass
      • Another class cannot access the protected through a subclass
  3. It is legal to assign an instance of a subclass to a reference variable of the parent type.

    • Every object of subclass type is guaranteed to also be of superclass type. Though this does not work the other way around
  4. Method overriding: a subclass can change the behavior of a parent class method

    • A method in the subclass with the same signature is overriding
    • You cannot override a final method or a method that is private in the parent class
  5. When you create a child object, all its parent classes are instantiated

    • You can explicitly call a superclass' constructor from first line of the subclass constructer with the "super" keyword
      • Elsewhere, the super keyword can call overriden methods or hidden members from a superclass
    • You can cast an instance of a subclass to a parent class

Information

Description
Mind Map on Inheritance, created by Jeff Golub on 21/11/2019.
Created by
Jeff Golub
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?