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

Mind map

Inheritance

Rodolfo Gonzalez English

Map content

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

Information

Description
Mind Map on Inheritance, created by Rodolfo Gonzalez on 21/11/2019.
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?